The following sections describe the error model for v2 and v1 resource methods, respectively.
v2 Resource Error Model
By default, resource methods respond with a 200 OK status. When requests are unsuccessful, Open Cloud returns standard error codes. All error responses have the same format, which include:
- code - Represents the HTTP status code.
- message - A message that explains the error.
- details - An object that contains more information specific to the error.
Example Error
{
"code": "INVALID_ARGUMENT",
"message": "The provided filter is invalid.",
"details": [
{
...
}
]
}
Codes
The following table describes possible values for code.
Code | HTTP Status | Description |
---|---|---|
INVALID_ARGUMENT | 400 | You passed an invalid argument, such as an invalid universeId. You might also have missing or invalid headers, such as Content-Length and Content-Type. |
PERMISSION_DENIED | 403 | Your request doesn't have sufficient permissions or scopes to perform the operation. |
NOT_FOUND | 404 | The system can't find your specified resources, such as a data store entry. |
ABORTED | 409 | The operation was aborted. |
RESOURCE_EXHAUSTED | 429 | You don't have enough quota to perform the operation, typically due to sending too many requests. |
CANCELLED | 499 | The system terminates the request, typically due to a client side timeout. |
INTERNAL | 500 | Internal server error, typically due to a server bug. |
NOT_IMPLEMENTED | 501 | The server doesn't implement the API method. |
UNAVAILABLE | 503 | Service is unavailable, typically returned when the server is down. |
v1 Resource Error Model
All error responses have the same, standard format, which includes:
- An error field, which is a high-level cause that is applicable to all Open Cloud endpoints.
- An explanatory error message, which further explains the error.
- An errorDetails object, which covers more information of the error that is specific to each API.
To analyze the root cause of an error, refer to the value of the error field and the errorDetails field. Use the message field as a supplementary for error handling, as sometimes it might not cover the same level of details as the errorDetails field.
Example Standard DataStores Error Response
{
"error": "INVALID_ARGUMENT",
"message": "Invalid cursor.",
"errorDetails": [
{
"errorDetailType": "DatastoreErrorInfo",
"datastoreErrorCode": "InvalidCursor"
}
]
}
The example error response shows the high-level Open Cloud error as INVALID_ARGUMENT, the error message as InvalidCursor, and the errorDetails specific to data stores with the datastoreErrorCode as InvalidCursor. From the error and datastoreErrorCode fields of the response, you can understand that you passed an invalid cursor parameter that caused the error. You can then correct your cursor parameter to resolve the issue.
All ordered data stores error responses have the same format, which includes:
Example Ordered DataStores Error Response
{
"code": "INVALID_ARGUMENT",
"message": "Invalid cursor."
}
The code will contain a string of the high-level error while the message will contain specific details related to the error
Codes
Reference the following table for a summary of all high-level Open Cloud errors.
HTTP Status Code | Error | Descriptions |
---|---|---|
400 | INVALID_ARGUMENT | You passed an invalid argument, such as an invalid universeId. You might also have missing or invalid headers, such as Content-Length and Content-Type. |
403 | INSUFFICIENT_SCOPE | The request requires higher privileges than provided by the access token. |
403 | PERMISSION_DENIED | Your request doesn't have sufficient scope to perform the operation. |
404 | NOT_FOUND | The system can't find your specified resources, such as a data store. |
409 | ABORTED | The operation was aborted due to a conflict, such as publishing a place that is not part of the universe. |
429 | RESOURCE_EXHAUSTED | You don't have enough quota to perform the operation, typically due to sending too many requests. |
499 | CANCELLED | The system terminates the request, typically due to a client side timeout. |
500 | INTERNAL | Internal server error. Typically a server bug. |
501 | NOT_IMPLEMENTED | The server doesn't implement the API method. |
503 | UNAVAILABLE | Service unavailable. Typically the server is down. |