Caloriosa / caloriosa

Documentation, Wiki, Analysis, issues and reports for Caloriosa
https://caloriosa.com
0 stars 0 forks source link

REST status result (HTTP + additional codes) #3

Open purrplingcat opened 6 years ago

purrplingcat commented 6 years ago

Meta

Related: #2


REST status codes and messages

HTTP status

Success

Client error

Server error

Rest additional error codes and messages in JSON

If client request process fails or it's invalid, then server returns an error HTTP response (status 4xx, 5xx) and JSON payload is object error. Payload looks following:

{
  "error": {
    "status": 500,
    "type": "ERROR_TYPE",
    "message": "Error message"
  }
}

Error types

Type HTTP status Message
DUPLICATED 409 Duplicated content or resource
NOT_FOUND 404 Resource '%s' not found
PERMISSION_DENIED 403 Permission denied
UNAUTHORIZED 401 Unauthorized request
UNAVAILABLE 410 Requested resource or content is not available
INVALID_CREDENTIALS 400 Invalid credentials (login, password)
INVALID_TOKEN 401 Your token is not valid
TOKEN_EXPIRED 401 Token expired. Please re-login
MISSING_REQUIRED 422 Required fields '%s' missing ]
PASSWORD_REQUIRED 422 Password required for access this resource!
WEAK_PASSWORD 422 Choosed password is too weak
INVALID_PASSWORD 422 Choosed password is not valid
INVALID_USERNAME 422 Chossed username is not valid
INVALID_EMAIL 422 Your email is not valid
INVALID_DATA 422 Recieved data is not valid (validation)
DATA_PARSE_ERROR 400 Error during parsing data (syntax error in JSON)
METHOD_NOT_ALLOWED 405 You are used invalid method. (Valid methods: POST, GET, PUT, PATCH, DELETE, HEAD, OPTIONS)
NOT_IMPLEMENTED 501 Not implemented
TIMED_OUT 408 Resource request timed out
BUSY 429 Service is busy
SERVICE_UNAVAILABLE 503 Service temporarily unavailable
SERVER_ERROR 500 Internal server error