Error Codes
Reference for all error codes returned by the FaraCore API.
Error Response Format
All errors follow this format:
{
"error": {
"code": "ERROR_CODE",
"message": "Human-readable error message",
"details": {}
}
}Action Errors
ACTION_NOT_FOUND
Status: 404
Description: The requested action does not exist.
{
"error": {
"code": "ACTION_NOT_FOUND",
"message": "Action not found: abc123"
}
}ACTION_NOT_EXECUTABLE
Status: 400
Description: Action cannot be executed in its current state.
ACTION_REQUIRES_APPROVAL
Status: 400
Description: Action requires approval before execution.
Policy Errors
POLICY_NOT_FOUND
Status: 404
Description: The requested policy does not exist.
POLICY_VALIDATION_ERROR
Status: 422
Description: Policy file has validation errors.
{
"error": {
"code": "POLICY_VALIDATION_ERROR",
"message": "Policy validation failed",
"details": {
"errors": ["Rule 1: missing 'match' field"]
}
}
}Authentication Errors
UNAUTHORIZED
Status: 401
Description: Authentication required or invalid token.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
}Validation Errors
VALIDATION_ERROR
Status: 422
Description: Request validation failed.
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"details": {
"field": "tool",
"error": "Field is required"
}
}
}Server Errors
INTERNAL_ERROR
Status: 500
Description: Internal server error.
DATABASE_ERROR
Status: 500
Description: Database operation failed.
SDK Error Classes
SDKs provide custom error classes:
Python SDK
from faracore.sdk import (
GovernorError,
GovernorTimeoutError,
GovernorAuthError,
GovernorConnectionError
)Node.js SDK
import {
GovernorError,
GovernorTimeoutError,
GovernorAuthError,
GovernorConnectionError,
PendingAction
} from "faracore";Handling Errors
Always check error codes and handle them appropriately:
try {
const action = await submitAction(...);
} catch (error) {
if (error.code === 'UNAUTHORIZED') {
// Handle authentication error
} else if (error.code === 'VALIDATION_ERROR') {
// Handle validation error
} else {
// Handle other errors
}
}