Skip to content

Pretty Error 😫 Stack Viewer for NestJS Framework 🛠️

License

Notifications You must be signed in to change notification settings

lsurma/nestjs-flub

 
 

Repository files navigation

Coverage Status

Nestjs Flub

Pretty ErrorHandler 😫, Stack Viewer for Nestjs Framework 🛠️

it's just a simple Filter for Catching the Errors

Features

  1. HTML reporter

  2. JSON reporter, if request accepts a json instead of text/html.

  3. Sorted frames of error stack.

  4. Themes

Dark Theme

dark

Light Theme

light

Install

npm install nestjs-flub --save

Simple Usage

Just add this filter as you used to add any filters

import { FlubErrorHandler } from 'nestjs-flub';
@Controller('cats')
@UseFilters(new FlubErrorHandler())
export class CatsController { 

@Get('/error')
  throwError() {
    throw new Error('Very Bad Error');
  }
}

Configuration

FlubErrorHandler accepts an object as an option to configure the Error Handler
for now it only have two Options

theme: string; // for themes ['dark', 'light', 'default']
quote: boolean; // for displaying  very good quotes

example

@UseFilters(new FlubErrorHandler({ theme: 'dark', quote:true }))

Theming

copy /src/themes/error.default.mustache and play

TODO

  • Write Tests
  • list syntax required

Contributing

You are welcome with this project for contributing, If you have new themes just make a new PR with and simple image for the theme

Global filters

Use flub error handler for all controllers

async function bootstrap() {
  const app = await NestFactory.create(ApplicationModule);
  app.useGlobalFilters(new FlubErrorHandler());
  await app.listen(3000);
}
bootstrap();

About

Pretty Error 😫 Stack Viewer for NestJS Framework 🛠️

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 89.5%
  • TypeScript 10.5%