https://github.com/velddev/aspnetcore.exceptions
AspNetCore exception-based error handler
https://github.com/velddev/aspnetcore.exceptions
Last synced: about 1 year ago
JSON representation
AspNetCore exception-based error handler
- Host: GitHub
- URL: https://github.com/velddev/aspnetcore.exceptions
- Owner: velddev
- License: mit
- Created: 2020-12-29T22:15:01.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-30T22:45:53.000Z (over 3 years ago)
- Last Synced: 2025-02-08T07:42:23.918Z (over 1 year ago)
- Language: C#
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AspNetCore.Exceptions
AspNetCore exception-based error handler
## Examples
### With attributes
For existing exceptions, a simple attribute to define the returning status code.
```cs
[StatusCode(400)]
class MyException : Exception
{
...
}
```
### With parent types
To define a new exception which is going to be handled, use `HttpException` as your parent class.
```cs
class MyException : HttpException {
public MyException()
: base(400)
{}
}
```
### With message
To create a user-friendly response message
```cs
class MyException : HttpException, IExplainableException {
public MyException()
: base(400)
{}
object Explain() {
return "Could not finish the example.";
}
}
```