Resolver Emitting Error ` ERROR Error: "[object Object]" `
I have found solution for detailed error working in firefox. Its based on defining custom error handler and inspecting error properties yourself. After these steps, the errors were displayed properly, no need to switch to chrome.
- Define custom error handler class:
import { ErrorHandler } from '@angular/core'
export class MyErrorHandler implements ErrorHandler {
handleError(error: any) {
// console.error(Object.getOwnPropertyNames(error))
// Object.getOwnPropertyNames(error).forEach(p => console.error(error[p]))
console.error(error.fileName, error.lineNumber, ':', error.columnNumber, '\n', error.message, error.rejection)
}
}
- Then register it as provider in main component
@NgModule({
declarations: []
imports: []
providers: [{provide: ErrorHandler, useClass: MyErrorHandler}], // <-- register MyErrorHandler
bootstrap: [RootComponent]
})
export class AppModule { }
This lack of detailed error occurred when using Mozilla Firefox
. so what you need to do is to switch over to Google Chrome
to see the specific error.
UPDATED:
You can also Store the error as Global Variable
then you can type temp0.message
to see the actual error message
In console you can store errors like
ERROR Error: "[object Object]"
as global variable
and then get error message from object temp0.message