/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
integration/hello-world/src/errors/errors.controller.ts
28 строк
531 B
Rick Dutour Geerling
fix(express): always return errors as application/json
31 окт 2022, 14:09
Не верифицирован
31 окт 2022, 14:09
ddf3301
Код
Авторство
О чём код?
import { BadRequestException, Controller, Get, Header } from '@nestjs/common'; @Controller() export class ErrorsController { @Get('sync') synchronous() { this.throwError(); } @Get('async') async asynchronous() { this.throwError(); } @Get('unexpected-error') @Header('Content-Type', 'application/pdf') unexpectedError() { throw new Error(); } throwError() { throw new BadRequestException({ statusCode: 400, error: 'Bad Request', message: 'Integration test', }); } }