Comments (15)
I just tried it. Its working really great, exactly what I needed.
from globalexceptionhandlerdotnet.
At the moment there isn't, but I'd be open to adding an overload to ReturnStatusCode(...)
along the lines of:
ReturnStatusCode(Func<Exception, HttpStatusCode>)
from globalexceptionhandlerdotnet.
Cool, should I work on a PR or is this something you would like to take?
from globalexceptionhandlerdotnet.
I'm currently doing some work on the API so I can do it as a part of that 👍
from globalexceptionhandlerdotnet.
Any idea when to expect this enhancement?
from globalexceptionhandlerdotnet.
Just finishing off the last few bits (I'm working on a major release) so it should be done in the next few days.
from globalexceptionhandlerdotnet.
Thanks for your patience @shorbachuk,
I've now released a beta package which includes this functionality (it's included within a major version bump I was working on which includes some breaking changes, but they're just method renames). If you'd like to give it a try I'd love to hear how you get on with it.
The new version can be found here https://www.nuget.org/packages/GlobalExceptionHandler/4.0.0-beta1 and the release notes here.
from globalexceptionhandlerdotnet.
I tried the beta. Agree with all the renames, they make a lot more sense.
I had to do:
x.Map<HttpStatusCodeException>().ToStatusCode(ex => (int)((HttpStatusCodeException)ex).StatusCode);
which is maybe not as clean as I would like, but for sure solves my problem. Thank you
from globalexceptionhandlerdotnet.
I'd love to be able to pass the generic type passed in at Map<T>
all the way down to .ToStatusCode(Func<T, int> x)
but unfortunately my GenericFu isn't up to scratch. I'd definitely welcome a PR if you can see some options for making this better?
Another option would also be to add the following overload for those that are using (by choice or necessity) System.Net.HttpStatusCode
which would at the very least remove the need to cast the status code to an int?
IHandledFormatters ToStatusCode(Func<Exception, int> statusCodeResolver);
IHandledFormatters ToStatusCode(Func<Exception, HttpStatusCode> statusCodeResolver); // Could add this overload?
The way I see it is it's still in beta so now is the time to make any changes.
from globalexceptionhandlerdotnet.
#25 also adds the overloads to stop people having to cast System.Net.HttpStatusCode
to an int, this seams especially helpful in this instance when you can't control the property type within an exception thrown.
from globalexceptionhandlerdotnet.
@shorbachuk New version with these changes has been uploaded to NuGet. Give it a whirl and let me know what you think.
from globalexceptionhandlerdotnet.
Great, I'll close this off then. Thanks for the feature suggestion(s)!
from globalexceptionhandlerdotnet.
Any plans to take this out of beta?
from globalexceptionhandlerdotnet.
@shorbachuk Yeah, can do it this weekend.
from globalexceptionhandlerdotnet.
@shorbachuk Just realised I didn't do this! Will do it today, I promise!
Edit: I presume it's all working for you and you've not run into any issues?
from globalexceptionhandlerdotnet.
Related Issues (20)
- No 'Access-Control-Allow-Origin' header is present on the requested resource. HOT 4
- Do not restrict to return pre-defined http status codes HOT 3
- Unhandled exception log HOT 1
- any future plans for "problem+json"? HOT 3
- ASP.Net Core 2.1 Issue HOT 7
- Is This Repo Alive? HOT 2
- Add property to indicate whether the exception has handled or not
- Handling a specific exception in MVC Core 2.1 HOT 2
- Access to mapped status code in OnError handler HOT 9
- Logging Session Id HOT 5
- Allow content negotiation in .ResponseBody() HOT 1
- OnError endpoint and exception map HOT 4
- Is it possible to add a non-generic method of Map<T>() ?
- Doesn't handle custom exceptions in net.core 3.1 HOT 8
- How to configure exception to error page
- Why I am not able to get the latest GlobalExceptionHandlerDotNet 4.0.3 from nuget
- can not handle api constructor exception
- Was v5 never released?
- How to handle the response in unit test cases?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from globalexceptionhandlerdotnet.