@rebase-team/universal-catcher
v0.0.11
Published
<h1 align="center">Universal Catcher</h1> <p align="center">This library was designed to shows errors in a beautiful and presentable way with detailed information about the angular errors.</p>
Downloads
4
Readme
You will need (>= Angular 9) to use this library and an Ionic project (>= v3).
Installation
npm install @rebase-team/universal-catcher
Usage examples
> APP.MODULE.TS
import { AppComponent } from "./app.component";
import { NgModule, ErrorHandler } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { IonicModule, IonicRouteStrategy } from "@ionic/angular";
import { UniversalCatcherService, UniversalHandler } from "@rebase-team/universal-catcher";
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
IonicModule.forRoot()
],
providers: [
UniversalCatcherService,
{ provide: ErrorHandler, useClass: UniversalHandler }
],
bootstrap: [AppComponent],
exports: []
})
export class AppModule { }
> HOME.PAGE.TS
import { Component } from "@angular/core";
import { UniversalCatcherService } from "@rebase-team/universal-catcher";
import { AppModule } from 'src/app/app.module';
@Component({
selector: "app-home",
templateUrl: "home.page.html",
styleUrls: ["home.page.scss"],
})
export class HomePage implements OnInit {
constructor(private catcherService: UniversalCatcherService) {
//Set the Error Catcher handler and get the error in Angular way (_ngErr)
//and error in Universal Catcher way (ucErr).
//Enjoy the library :)
this.catcherService.setErrorCatcher = (_ngErr, ucErr) => {
console.log(`Error message: ${ucErr.Message}`);
console.log(`Error time: ${ucErr.Time}`);
console.log(`Error file name: ${ucErr.Trace[0].File}`);
console.log(`Error source code line: ${ucErr.Trace[0].Line}`);
console.log(`Caused by: ${ucErr.Trace[0].Source}`);
};
}
}
Output in Developer Tools (Chrome, Mozilla, Opera)
Metadata
Muryllo Pimenta de Oliveira – [email protected]
Distribuído sobre a licença MIT. Veja LICENSE
para mais informações.
Contributing
- Fork it (https://github.com/MurylloEx/Universal-Catcher/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request