npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

log-that-error

v1.0.1

Published

An angular library that is used to handle the errors by logging it to a backend/server so that the admin can be notified.

Downloads

5

Readme

###Log That Error.

This library was generated with Angular CLI version 8.0.1.

by Suvab Baral([email protected]) and Sanjay Murugan([email protected])

Contact for any queries.


###Description -:

log-that-error is an angular package used for handling errors that have occured in the angular application and also help notify the admins by logging the errors to a backend / server.


###Installation -:

    npm install log-that-error 

###Dependencies :

This package has 'guid-typescript','extract-stack' and 'bootstrap' as dependencies ,so if you have not pre installed these package , please do install them :

#####Bootstrap :

    npm install bootstrap

Once bootstrap is installed , please include the following on ' style.css ' file on your app , to make bootstrap available globally on your app.

    @import '~bootstrap/dist/css/bootstrap.min.css';

#####Extract-Stack :

    npm install extract-stack

#####Guid-Typescript :

    npm install guid-typescript

###Usage Guide -:

The log-that-error simply raises an error event with errorMessage(string object) and errorDetail(error object) as parameters whenever an error occurs , anyone can subscribe to these events using the ErrorHandlerService class.

In app.module.ts add the following snippet of code. -:

    imports :[
        ....,
        HTTPClientModule                   //( from @angular/common/http )
    ],


    providers :[ 

        { 

            provide : ErrorHandler,         //( from @angular/core ) 

            useClass :GlobalErrorHandler    //( from log-that-error ) 

        }, 

        { 

            provide : HTTP_INTERCEPTOR,      //( from @angular/common/http ) 

            useClass:HttpErrorInterceptor,   //( from log-that-error ) 

            multi : true 

        } 

    ] 

enterInDB( error : any ) is the method that can be used to log the error into the backend/server.The REST API Server URL can be set as per the requirement using the
setUrl(urls : string) method of the ErrorHandlerService class.

#####Make to set the url of your REST API , before pushing errors to the server. It is recommended you set the url in your class constructor.

Once the URL is set all the logs of the error can be viewed in the URL in JSON Format with primary components such as 'URL where the error occured', 'method name where the error occured' along with the entire error message.


###Example -:

/* 

    For setting the REST API URL 

*/ 

this.errorHandlerService.setUrl("YOUR URL"); 



 /* 

    For subscribing to the error event 

*/ 

    this.errorHandlerService.notify.subscribe((result) => { 

   

/*  

    For logging the error into the server 

*/ 

      this.errorHandlerService.enterInDB(result.errorDetail); 

    });  

###Snapshots :

Dummy Application A Dummy application that we tested our package on.

Error Notification Snapshot For testing purposes , we used 'npm json-server' and logged the errors. Above displayed is the snapshot of the same.

OnAPP Notification Error notification to the user and error details provided in the log for the service provider.


###Additional Feature (>v1.0.0)

We have also included a service named 'Business Exception Service' which can be used to notify the user about the essential criteria for running the application smoothly, also known as Business Exception.

Use the throwWarning( errorMesssge : string ) to send a warning to the user.This warning can also be pushed to the server if need be using the pushToServer(errorMessage : string , Function : any). Pass the function name as 'this.(your function name)' Example : If you are calling the pushToServer() from your constructor : pushToServer("ERROR",this.constructor)