Cannot find name 'ErrorHandler'

I have the error message “ERROR in src/app/app.module.ts(20,15): error TS2304: Cannot find name ‘ErrorHandler’.
[ng] src/app/app.module.ts(20,39): error TS2304: Cannot find name ‘IonicErrorHandler’.” following the docs “build your first app” after inserting " ```
providers: [
StatusBar,
SplashScreen,
Camera,
{provide: ErrorHandler, useClass: IonicErrorHandler}
],

What can I do?

can u show the code of the class IonicErrorHandler and app.module.ts? did you import both the ErrorHandler and IonicErrorHandler class in app.module.ts?

I just followed https://ionicframework.com/docs/angular/your-first-app/.

import { NgModule } from ‘@angular/core’;
import { BrowserModule } from ‘@angular/platform-browser’;
import { RouteReuseStrategy } from ‘@angular/router’;

import { IonicModule, IonicRouteStrategy } from ‘@ionic/angular’;
import { SplashScreen } from ‘@ionic-native/splash-screen/ngx’;
import { StatusBar } from ‘@ionic-native/status-bar/ngx’;

import { AppRoutingModule } from ‘./app-routing.module’;
import { AppComponent } from ‘./app.component’;
import { Camera } from ‘@ionic-native/camera/ngx’;
@NgModule({
declarations: [AppComponent],
entryComponents: ,
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
Camera,
{provide: ErrorHandler, useClass: IonicErrorHandler}
],
bootstrap: [AppComponent]
})
export class AppModule {}

There is no such thing as IonicErrorHandler in Ionic v4 which you seem to use, the doc is probably not up-to-date.

If you don’t have particular error handling requirements and as you are starting an app you could just skip the line

{provide: ErrorHandler, useClass: IonicErrorHandler}

for now on.

1 Like

don’t you have a class called IonicErrorHandler? i didn’t see that in the imports. how do u import that in
this line
{provide: ErrorHandler, useClass: IonicErrorHandler}

refer this https://www.nextfaze.com/blog/production-error-handling-in-ionic/ if u using ionic 3.

Ok, that helped! I use Ionic 5.2.3.

In the same docs I should

"Finally, add the “takePicture” method, already wired up to execute once the camera button has been tapped:

takePicture() {
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}

this.camera.getPicture(options).then((imageData) => {
  this.currentImage = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
 // Handle error
 console.log("Camera issue:" + err);
});

}"
But in which file?

what do you mean by which file?