Skip to main content

Error Code Reference

Complete list of error codes used in EZ-Console.

Error Code Format

Format: E + HTTP status code + sequence number

Example: E4001 = Error 400 (Bad Request), sequence 01

Client Errors (4xx)

Bad Request (400)

CodeDescriptionSolution
E4001Invalid request parametersCheck request format and required fields
E4002Validation failedFix validation errors in request body
E4003Invalid JSON formatEnsure request body is valid JSON
E4004Invalid UUID formatUse valid UUID format
E4005Invalid email formatUse valid email address
E4006Invalid date formatUse ISO 8601 format

Unauthorized (401)

CodeDescriptionSolution
E4012Invalid or missing auth tokenLogin again to get new token
E4013Token expiredRefresh token or login again
E4014Invalid credentialsCheck username and password
E4015Account lockedContact administrator
E4016MFA requiredProvide MFA code

Forbidden (403)

CodeDescriptionSolution
E4031Permission deniedRequest permission from administrator
E4032Insufficient permissionsCheck your role permissions
E4033Account disabledContact administrator
E4034Password expiredChange your password

Not Found (404)

CodeDescriptionSolution
E4041Resource not foundCheck resource ID
E4042User not foundVerify user exists
E4043Endpoint not foundCheck API endpoint

Conflict (409)

CodeDescriptionSolution
E4091Resource already existsUse different name or identifier
E4092Username already existsChoose different username
E4093Email already existsUse different email

Unprocessable Entity (422)

CodeDescriptionSolution
E4221Business rule violationReview business rules
E4222Insufficient stockCheck available quantity
E4223Invalid state transitionCheck current state

Too Many Requests (429)

CodeDescriptionSolution
E4291Rate limit exceededWait and retry later

Server Errors (5xx)

Internal Server Error (500)

CodeDescriptionSolution
E5001Internal server errorContact support with error details
E5002Database errorCheck database connection and logs
E5003External service errorCheck external service status
E5004File operation errorCheck file permissions
E5005Configuration errorVerify configuration

Service Unavailable (503)

CodeDescriptionSolution
E5031Service temporarily unavailableTry again later
E5032Database unavailableCheck database status
E5033Maintenance modeWait for maintenance to complete

Error Response Format

All errors follow this format:

{
"code": "E4001",
"err": "Human-readable error message"
}

Handling Errors

Frontend

try {
const data = await apiGet('/users');
} catch (error) {
const errorCode = error.response?.data?.code;
const errorMessage = error.response?.data?.err;

switch (errorCode) {
case 'E4012':
// Redirect to login
window.location.href = '/login';
break;
case 'E4031':
message.error('Permission denied');
break;
default:
message.error(errorMessage || 'An error occurred');
}
}

Backend

product, err := c.svc.Product().GetByID(ctx.Request.Context(), id)
if err != nil {
if errors.Is(err, service.ErrNotFound) {
util.RespondWithError(ctx, util.NewErrorMessage("E4041", "Product not found"))
return
}
util.RespondWithError(ctx, util.NewErrorMessage("E5001", "Failed to get product", err))
return
}

Logging

All errors are automatically logged with context:

{
"level": "error",
"msg": "Failed to get product",
"code": "E5001",
"err": "database connection failed",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"user_id": "user-uuid",
"timestamp": "2024-01-01T12:00:00Z"
}

Best Practices

DO ✅

  1. Use appropriate error codes
  2. Provide helpful error messages
  3. Log detailed errors server-side
  4. Return sanitized errors to clients
  5. Handle specific error cases

DON'T ❌

  1. Don't expose internal errors
  2. Don't return stack traces
  3. Don't ignore error handling
  4. Don't use generic errors everywhere
  5. Don't expose sensitive information

Next Steps