0.0.11 • Published 3 years ago

@rebase-team/universal-catcher v0.0.11

Weekly downloads
9
License
-
Repository
-
Last release
3 years ago

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 – muryllo.pimenta@upe.br

Distribuído sobre a licença MIT. Veja LICENSE para mais informações.

Contributing

  1. Fork it (https://github.com/MurylloEx/Universal-Catcher/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request
0.0.10

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago