Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nestjsx/nestjs-flub
Pretty Error 😫 Stack Viewer for NestJS Framework 🛠️
https://github.com/nestjsx/nestjs-flub
errors nestjs
Last synced: about 6 hours ago
JSON representation
Pretty Error 😫 Stack Viewer for NestJS Framework 🛠️
- Host: GitHub
- URL: https://github.com/nestjsx/nestjs-flub
- Owner: nestjsx
- License: mit
- Created: 2017-11-24T10:05:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T11:21:15.000Z (12 months ago)
- Last Synced: 2024-10-29T22:37:19.506Z (about 2 months ago)
- Topics: errors, nestjs
- Language: Mustache
- Homepage:
- Size: 1.19 MB
- Stars: 250
- Watchers: 6
- Forks: 17
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome - nestjsx/nestjs-flub - Pretty Error 😫 Stack Viewer for NestJS Framework 🛠️ (Mustache)
README
Nestjs Flub
Pretty ErrorHandler 😫, Stack Viewer for [Nestjs Framework](https://nestjs.com/) 🛠️
> 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](https://files.gitter.im/nestjs/nestjs/qkqB/error-dark.png)### Light Theme
![light](https://files.gitter.im/nestjs/nestjs/z6X6/error-light.png)## Install
```bash
npm install nestjs-flub --save
```## Simple Usage
Just add this filter as you would any filter:
```typescript
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 optional object to configure the Error Handler. For now, it only has two Options:
```typescript
theme: string; // for themes ['dark', 'light', 'default']
quote: boolean; // for displaying very good quotes
```
example
```typescript
@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 to contribute to this project. If you want to add new themes, make a new PR containing the theme and a simple image to represent it
## Global filters
Use flub error handler for all controllers
```typescript
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
app.useGlobalFilters(new FlubErrorHandler());
await app.listen(3000);
}
bootstrap();