Overview
The TrackGeek API uses a centralized error handling system that provides consistent, structured error responses across all endpoints. All errors follow a standard format with error codes and HTTP status codes.Error Response Format
All API errors return a JSON response with the following structure:- code: A string constant identifying the specific error type
- status: The HTTP status code associated with the error
HTTP Status Codes
The API uses standard HTTP status codes to indicate the type of error:| Status Code | Meaning | Usage |
|---|---|---|
| 400 | Bad Request | Invalid request parameters or malformed data |
| 401 | Unauthorized | Missing or invalid authentication |
| 404 | Not Found | Requested resource does not exist |
| 409 | Conflict | Resource already exists or constraint violation |
| 415 | Unsupported Media Type | Invalid file type (e.g., image uploads) |
| 422 | Unprocessable Entity | Validation error or invalid entity state |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Unexpected server error |
| 503 | Service Unavailable | External service unavailable |
Common Error Codes
Authentication & Authorization
Resource Not Found
Conflict Errors
Database conflicts (like unique constraint violations) are automatically mapped to the
DATABASE_CONFLICT error code.Validation Errors
Rate Limiting
External Service Errors
Upload Errors
Database Exception Handling
The API automatically converts Prisma database errors into user-friendly error responses:Prisma Error Mappings
| Prisma Error Code | Error Response | Description |
|---|---|---|
| P2002, P2003 | DATABASE_CONFLICT | Unique constraint or foreign key violation |
| P2025 | DATABASE_ITEM_NOT_FOUND | Record not found in database |
| Validation Error | DATABASE_VALIDATION_ERROR | Invalid data type or format |
These mappings are handled automatically by the
HttpExceptionFilter at src/shared/filters/http-exception.filter.ts:14-32.Handling Errors in Your Application
TypeScript Example
JavaScript Example
Python Example
Complete Error Code Reference
For a complete list of all error codes, see the source atsrc/shared/constants/error-codes.ts. The main categories include:
- User & Profile Errors:
USER_NOT_FOUND,PROFILE_NOT_FOUND,USER_CANNOT_FOLLOW_SELF, etc. - Content Errors:
GAME_NOT_FOUND,MOVIE_NOT_FOUND,ANIME_NOT_FOUND,BOOK_NOT_FOUND, etc. - Review Errors:
REVIEW_NOT_FOUND,REVIEW_ALREADY_EXISTS - List Errors:
LIST_NOT_FOUND,LIST_ALREADY_EXISTS,LIST_ITEM_NOT_FOUND - Favorite Errors:
FAVORITE_NOT_FOUND,FAVORITE_ALREADY_EXISTS - Database Errors:
DATABASE_CONFLICT,DATABASE_ITEM_NOT_FOUND,DATABASE_VALIDATION_ERROR - Service Errors:
GAME_SERVICE_UNAVAILABLE,TMDB_SERVICE_UNAVAILABLE, etc.