Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to render view dynamically by http status on ExceptionFilter #358

Open
hanadamaru opened this issue Dec 8, 2022 · 1 comment
Open

Comments

@hanadamaru
Copy link

I wish render 500 error page when catch exception on my ExceptionFilter.
but display just white page.

catch(exception: Error, host: ArgumentsHost) {
	const ctx                         = host.switchToHttp();
	const response = ctx.getResponse();
	const exceptionStatus             = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
	const data                        = exceptionStatus >= HttpStatus.INTERNAL_SERVER_ERROR ? exception['stack'] : undefined;
		
	this.logger.error(Object.assign({ exceptionStatus: exceptionStatus, msg: exception['message'], stack: data }));

	response.view('errors/500.hbs', {title: '500 ERROR'});
}
@Fdawgs
Copy link
Member

Fdawgs commented Jun 3, 2023

Did you manage to solve this @hanadamaru?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants