Skip to content

Review error handling for all endpoints based on new back-end format for errors #46

@rozita-hasani

Description

@rozita-hasani

Title: Update Error Handling to Match New Back-End Format

Goal:
Ensure consistent and clear error handling by aligning with the new back-end error format. Create a centralized function to handle all errors efficiently.

New Back-End Error Format Examples:

  1. Validation Error:
{
  "status": 400,
  "error": "BAD_REQUEST",
  "message": "Validation failed: One or more fields contain invalid values.",
  "path": "/auth/register",
  "timestamp": "2025-01-19T11:28:28.6543834",
  "details": [
    {
      "field": "password",
      "message": "organization.password.size",
      "constraint": "Size",
      "value": "123"
    }
  ]
}
  1. Server Error:
{
    "status": 500,
    "error": "INTERNAL_SERVER_ERROR",
    "message": "User already exists with email: mohsenk.work@gmail.com",
    "path": "/auth/register",
    "timestamp": "2025-01-19T11:27:25.8701854",
    "details": []
}

Tasks:

  1. Centralized Error Handling:

    • Implement a utility function to process and display errors.
    • Format errors for easy understanding by users and developers.
  2. Error Categorization:

    • Handle validation errors (400) and server errors (500) differently.
    • Use details for field-specific messages in validation errors.
  3. User-Friendly Messages:

    • Provide clear and actionable feedback (e.g., "Password must be at least 8 characters").
    • Simplify server error messages to avoid exposing sensitive data.
  4. Testing:

    • Ensure all endpoints use the new error-handling approach.
    • Test with various scenarios like missing fields, invalid inputs, and server issues.

Acceptance Criteria:

  • Centralized error handling is implemented and used across all endpoints.
  • Errors are clear, consistent, and actionable.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions