https://github.com/tommaple/result
An abstraction which contains the value or the error of the operation. It can be mapped to the HTTP reponse if needed.
https://github.com/tommaple/result
csharp csharp-lib csharp-library dotnet dotnet-core result rfc-7807 rfc-9457
Last synced: 8 months ago
JSON representation
An abstraction which contains the value or the error of the operation. It can be mapped to the HTTP reponse if needed.
- Host: GitHub
- URL: https://github.com/tommaple/result
- Owner: TomMaple
- License: mit
- Created: 2024-08-26T02:51:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-25T03:46:30.000Z (over 1 year ago)
- Last Synced: 2025-03-20T07:18:39.404Z (about 1 year ago)
- Topics: csharp, csharp-lib, csharp-library, dotnet, dotnet-core, result, rfc-7807, rfc-9457
- Language: C#
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Result
An abstraction which contains the value or the error of the operation. It can be mapped to the HTTP reponse if needed.
# Project status: EARLY STAGE
# Why
I decided to create a new implementation to address a few missing functionalities in other libraries (e.g., i18n, support for more precise error descriptions) and to better follow industry standards ([RFC 9457](https://datatracker.ietf.org/doc/html/rfc9457)).
# Error Response
Example
```json
{
"type": "https://example.com/probs/out-of-credit",
"status": 400,
"title": "You do not have enough credit.",
"detail": "Your current balance is 30, but that costs 50.",
"instance": "/accounts/12345/msgs/abc",
"errors": [
{
"pointer": "#/age",
"detail": "must be a positive integer",
"detailTemplate": {
"messageId":"user.details.age.mustBePositive"
}
},
{
"pointer": "#/profile/colour",
"detail": "must be ‘green’, ‘red’ or ‘blue’",
"detailTemplate": {
"messageId": "user.profile.colour",
"params": {
"validValueIds": [
"user.profile.colour.green",
"user.profile.colour.red",
"user.profile.colour.blue"
]
}
}
}
],
"detailTemplate": {
"messageId": "user.account.balance.tooLow",
"params": {
"errorCode": "UAB17",
"accounts": [
{
"title": "Main (***9456)",
"url": "/accounts/12345"
},
{
"title": "Main (***3357)",
"url": "/accounts/67890"
}
],
"currentBalance": 30,
"requiredBalance": 50
}
},
"location": "252e0b7f-b21c-44ab-bda0-c72fe943b886"
}
```
# Contribution
Please contact author: tom.maple(at)outlook.com