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

@uoa/error-pages

v16.2.2

Published

Install library using command

Downloads

152

Readme

Uoa Error Pages

Usage

Install library using command

npm install @uoa/error-pages

In your app.module.ts import ErrorPagesModule, eg:

import { ErrorPagesModule } from '@uoa/error-pages';

Include ErrorPagesModule in your imports[].

Create an ErrorRoutingModule to define the error page child route

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { ErrorPagesModule, ErrorPage } from '@uoa/error-pages';

@NgModule({
  imports: [ErrorPagesModule, RouterModule.forChild([{ path: '', component: ErrorPage }])],
  exports: [RouterModule],
})
export class ErrorRoutingModule {}

Go to routing module of application and add error route to routes. Here is an example:

{
    path: 'error/:errorCode',
    loadChildren: () => import('./error-routing.module').then((m) => m.ErrorRoutingModule),
}

If you want to handle specific error code for any endpoint inside project. import BypassErrorService to your Service

import { BypassErrorService } from '@uoa/error-pages';

and call following method before your api call:

this._bypass.bypassError('${url}', [409, 401, 504, 404]);

Library will skip mentioned error statuses for given end point.

Default Error codes are as follow:

  clientErrorCodes =  [400, 401, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 418, 429, 431];
  serverErrorCodes = [500, 501, 502, 503, 504, 505, 506];

Error Template is defined for all the above codes.

Override Error codes and Error Content

If you want to override default error codes and templates, include UoaErrorsConfig as a provider:

{ provide: UoaErrorsConfig, useClass: AppErrorsConfig }

You will need to create this AppErrorsConfig class, where you assign new values to existing objects or add new objects properties. Here is an example:

import { UoaErrorsConfig } from '@uoa/error-pages';

export class AppErrorsConfig extends UoaErrorsConfig {
  constructor() {
    super();

    this.serverErrorCodes = [501, 504, 505];

    this.ErrorPageContent['ErrorCode400'] = { title: 'Custom title', content: 'Custom description' };

  }
}

Similarly if need to change button's text on error page override variable in AppErrorsConfig class.

this.returnButtonText = 'Go To Home Page';

Use Toaster instead of Error Page to show Errors

If you want to use toaster instead of Error page to show error message, firstly set config variable 'showErrorAsToast' in AppErrorsConfig class.

this.showErrorAsToast = true;

Afterwards include ErrorToastService as a provider: import { ErrorToastService } from '@uoa/error-pages';

{ provide: ErrorToastService, useClass: AppToastService },

You will need to create AppToastService class. It is up to user to use ionic ToastController or different toast library.

AppToastService class implementation using Ionic ToastController:

import { Injectable } from '@angular/core';
import { ToastController } from '@ionic/angular';
import { ErrorToastService, ErrorContentDto } from '@uoa/error-pages';

@Injectable({
  providedIn: 'root',
})
export class AppToastService implements ErrorToastService {
  constructor(private _toastCtrl: ToastController) {}

  async createToast(content: ErrorContentDto) {
    const toast = await this._toastCtrl.create({
      message: content.content,
      header: content.title,
      position: 'middle',
      color: 'dark',

      buttons: [
        {
          text: 'Ok',
          role: 'cancel',
        },
      ],
    });
    toast.present();
  }
}