Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Startup - Handle Exceptions #486

Closed
Tratcher opened this issue Nov 17, 2015 · 6 comments
Closed

Startup - Handle Exceptions #486

Tratcher opened this issue Nov 17, 2015 · 6 comments

Comments

@Tratcher
Copy link
Member

From @Fosol on November 17, 2015 23:1

I'd like to know how to handle exceptions on Startup so that I can return an appropriate error page within MVC (if possible).

I also want to be able to check for invalid configuration values and return an appropriate error page. My specific use case is when private keys for authentication and authorization are incorrect or missing. I want to be able to get the server up and running without them but force an error page as the response to any request.

Copied from original issue: aspnet/HttpAbstractions#484

@Tragetaschen
Copy link
Contributor

Isn't this just a specific way of setting up the request pipeline with a few ifs in the Startup.Configure method? This doesn't sound like it's expected to automatically heal during runtime (which would probably be a bad idea anyways)

@Fosol
Copy link

Fosol commented Nov 18, 2015

What if the conditions required to initialize policies (authentication) are not configured correctly. I can't see an if statement working all that well since you would have to skip over critical startup code. Not to mention any named policies on controllers and endpoints would cause an immediate crash.

The only if I think I would want is a forced response that informs the user of the issue. I don't want the server to be unable to start.

@davidfowl
Copy link
Member

By default we actually catch all startup exceptions and show an error page (if in development or a flag is set). What more do you need?

@Fosol
Copy link

Fosol commented Nov 18, 2015

I didn't see this behaviour occurring. Perhaps I haven't configured Startup correctly? Is there specific steps that need to be taken to get this default behaviour?

@Tratcher
Copy link
Member Author

@Fosol What do you see then? You should get something like this on beta8 or later (in Development):
image

@Fosol
Copy link

Fosol commented Nov 18, 2015

I'm in the middle of migrating a bunch of code to beta8.

Just tested it in beta8 - I think that's the behaviour I'm looking for! Thank you.

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

No branches or pull requests

4 participants