Skip to content

Standardize Error Handling & API Response Format #128

@Denes-cilwal

Description

@Denes-cilwal

Currently, our error handling and response patterns are inconsistent across the backend.
There are multiple variations of JSON response structures (error, msg, data), unstructured error types, and missing standardized codes — making it difficult for both the frontend and logs to correlate issues.

This issue aims to standardize error handling, formatting, and propagation across the entire API layer using idiomatic Go and industry best practices.


Current Problems

  • APIError.Error() returns an empty string — breaks logging and error wrapping.
  • Multiple JoinError functions cause confusion and message inconsistencies.
  • Different response keys across endpoints (error, msg, data).
  • Internal errors (e.g., gorm.ErrRecordNotFound) are leaked to clients.
  • No consistent code field for frontend error mapping.
  • Pagination responses have a different format from others.
  • No centralized middleware for unified error handling and logging.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions