Error Handling and Status Codes
1. Common Error Codes and Handling
400 Bad Request:
Returned when the request is malformed or contains invalid data (e.g., missing required fields).401 Unauthorized:
Returned when the request lacks a valid token or the user is not authenticated.403 Forbidden:
Returned if the user does not have the required permissions to perform the action.404 Not Found:
Returned when the requested resource (e.g., function or job) does not exist.500 Internal Server Error:
Indicates a server-side issue, often due to an unexpected failure.
2. API Response Status Codes
200 OK:
The request was successfully processed.201 Created:
A resource (e.g., function or job) was successfully created.400 Bad Request:
The request was invalid or malformed.404 Not Found:
The requested resource could not be found.500 Internal Server Error:
A server-side error occurred.
3. Error Message Usage Guide
Error messages should be clear and help users understand what went wrong. Examples:
Invalid function name:
"Function name is required and must be a string of at least 3 characters."
Permission denied:
"You do not have permission to delete this function. Please contact your administrator."