https://github.com/gotidy/herr
https://github.com/gotidy/herr
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gotidy/herr
- Owner: gotidy
- License: apache-2.0
- Created: 2021-06-30T10:25:12.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-30T14:13:20.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T23:57:33.628Z (almost 2 years ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Herr
### Errors
`Herr` implements the error model of the well established
[Google API Design Guide](https://cloud.google.com/apis/design/errors). Additionally, it makes the fields `request` and `reason` available. A complete `Herr` error response looks like this:
```json
{
"error": {
"code": 400,
"status": "Bad Request",
"request": "8512585f-587a-40bf-9ec7-2937f10d1d97",
"reason": "INVALID_PARAMETER",
"items": [
{
"name": "user",
"code": "EMPTY",
"description": "User is not defined"
}
],
"details": [
{"additional": "info"}
],
"message":"foo"
}
}
```
### Open API Error description
[Open API file](openapi.yml)
```yaml
components:
schemas:
ErrorItem:
type: object
properties:
name:
type: string
description: Name of parameter or field.
example: error message
code:
type: string
description: Error code.
example: "Empty"
Description:
type: string
description: Description.
example: The field is empty
required:
- "name"
Error:
type: object
additionalProperties: false
properties:
code:
type: integer
description: HTTP status code.
example: 400
status:
type: string
description: Status.
example: "Bad Request"
reason:
type: string
description: Error reason.
example: INVALID_PARAMETERS
request_id:
type: string
description: Request ID.
example: c4b9df35-1716-4099-b24f-f844b5491e22
description:
type: string
description: Description.
example: Something went wrong.
debug:
type: string
description: Debug information.
example: S0011.
details:
type: object
items:
type: array
items:
$ref: "#/components/schemas/ErrorItem"
required:
- "status"
- "code"
```