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

Set exception handler feature in developer exception page #47554

Merged

Conversation

bjornen77
Copy link
Contributor

When using the developer exception page, the exception handler
feature is now set before invoking the problem details service.
This makes it possible to get the original exception when using
the problem details service if wanted.

Fixes# #47060

When using the developer exception page, the exception handler
feature is now set before invoking the problem details service.
This makes it possible to get the original exception when using
the problem details service if wanted.

Fixes dotnet#47060
@ghost ghost added area-runtime community-contribution Indicates that the PR has been added by a community member labels Apr 4, 2023
@ghost
Copy link

ghost commented Apr 4, 2023

Thanks for your PR, @bjornen77. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@JamesNK
Copy link
Member

JamesNK commented Apr 10, 2023

This is ok, but have we considered adding the exception to the problem details context?

public class ProblemDetailsContext
{
    public Exception? Exception { get; init; }
}

When the problem details context is written from one of the exception handler middleware, the exception would be set on the context.

Getting the exception from a feature is a semi-advanced concept. Having it available on the problem details context would be more straightforward.

cc @captainsafia @mitchdenny @BrennanConroy @amcasey

@bjornen77
Copy link
Contributor Author

I do not know if adding the exception to the context has been discussed, but I think it would be a good thing to do. Should we keep this change just to make the different exception handlers behave the same?

@captainsafia
Copy link
Member

Getting the exception from a feature is a semi-advanced concept. Having it available on the problem details context would be more straightforward.

FWIW, I don't think getting it from the feature is that advanced. If anything, it has a bit of an edge over the ProblemDetailsContext since it relies on an API that's been around for longer. That being said, I'm not opposed to adding an Exception to the ProblemDetails.

Should we keep this change just to make the different exception handlers behave the same?

I think we should go with this change because adding the Exception to the ProblemDetails context would be additive. We should set the feature in the DEP even if it was set in the exception so it is accessible to people not using the ProblemDetailsService.

I do not know if adding the exception to the context has been discussed, but I think it would be a good thing to do.

Would you be interested in submitting an API proposal for this via the template?

Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM given that I believe having the feature on the ProblemDetailsContext should happen in addition to this change.

@bjornen77
Copy link
Contributor Author

Would you be interested in submitting an API proposal for this via the template?

Sure, no problem!

@captainsafia captainsafia merged commit 0f65d69 into dotnet:main Apr 11, 2023
@ghost ghost added this to the 8.0-preview4 milestone Apr 11, 2023
@bjornen77 bjornen77 deleted the feat/add-exception-handler-feature branch April 12, 2023 05:32
@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants