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

Errorhandling #27

Merged
merged 5 commits into from
Jul 13, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,56 @@ Avoid including a key without a meaningful value:

### ✅

The error object needs to have the following:
- Be consistent
- Have all required info
- Easy parsable
- Should be possible to build a solid UI on top, guiding the user what happened, and how to move on

```json
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make sure all indentations are 4 spaces? Then it's aligned with the rest of the code snippets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe its me, but what do you mean here? can you do a example

Copy link
Contributor

Choose a reason for hiding this comment

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

I fixed the indentations locally.
Will push to this PR once I get access rights from @Casperhr 🙏

"error": {
"localizedTitle": "Title goes here", // Optional title localized for end user
"localizedMessage": "Message goes here", // Optional message localized for end user
"message": "Invalid format, digits required", // Message for developer
"isRecoverable": true, // Is the error handled in the UI is fatal or can it be recovered, eg: try again
"identifier": "PASSWORD_NOT_FOLLOWING_PATTERN", // Identifier which the consumer of the API can parse and switch case on
"source": "LoginService" // In micro services architecture, you might want to understand what service
},
"payload": {
"validationErrors": [
{
"field": "password",
"errors":
[
{
"type": "required",
"localizedMessage": "Please enter a password"
},
{
"type": "regex",
"localizedMessage": "Password format should have following: 8 charts, 1 small leter, 1 big letter & 1 number"
},
]
}
]
}
},
"metadata": {
"errorID": "1234-ABC" // Optional ID for if the error is stored in DB, APM, Bug tracking tools like Bugsnag, Sentry, Rollbar, New Relic etc.
}
}

```

### ⛔️

```json
{
"error": "Internal server error"
}
```

</details>

# Localization
Expand Down