Skip to main content

Error Handling

Console uses standard HTTP status codes and consistent error response formats.

HTTP Status Codes

CodeMeaning
200Success
201Created
400Bad request (business logic error)
401Not authenticated (invalid/missing token)
403Not authorized (insufficient permissions)
404Resource not found
422Validation error (invalid request format)
429Rate limit exceeded

Error Response Format

Business Logic Errors (400)

{
"error": "User with this email already exists",
"error_code": "USER_EMAIL_DUPLICATE"
}

Validation Errors (422)

{
"errors": [
{
"field": "email",
"message": "must be a valid email"
}
]
}

Common Error Codes

CodeMeaningAction
INVALID_CREDENTIALSWrong email/passwordCheck credentials
TOKEN_EXPIREDAccess token expiredRefresh token
FORBIDDENMissing permissionCheck user's groups
USER_EMAIL_DUPLICATEEmail already existsUse different email

Handling Errors

try {
const response = await fetch('/v1/users', {
headers: { 'Authorization': `Bearer ${token}` }
});

if (!response.ok) {
const error = await response.json();

if (response.status === 401) {
// Refresh token or redirect to login
} else if (response.status === 422) {
// Show validation errors to user
console.error(error.errors);
} else {
// Show generic error message
console.error(error.error);
}
}

return await response.json();
} catch (err) {
// Network error or API unreachable
console.error('Network error:', err);
}