Skip to main content

dbrest_core/error/
codes.rs

1//! DBRST error codes
2//!
3//! DBRST error codes used throughout dbrest.
4
5/// Configuration errors (000-099)
6pub mod config {
7    pub const DB_CONNECTION: &str = "DBRST000";
8    pub const UNSUPPORTED_PG_VERSION: &str = "DBRST001";
9    pub const INVALID_CONFIG: &str = "DBRST002";
10    pub const CONNECTION_RETRY_TIMEOUT: &str = "DBRST003";
11}
12
13/// API request errors (100-199)
14pub mod request {
15    pub const INVALID_QUERY_PARAM: &str = "DBRST100";
16    pub const INVALID_RPC_METHOD: &str = "DBRST101";
17    pub const INVALID_BODY: &str = "DBRST102";
18    pub const INVALID_RANGE: &str = "DBRST103";
19    // DBRST104 is no longer used (ParseRequestError)
20    pub const INVALID_FILTERS: &str = "DBRST105";
21    pub const UNACCEPTABLE_SCHEMA: &str = "DBRST106";
22    pub const MEDIA_TYPE_ERROR: &str = "DBRST107";
23    pub const NOT_EMBEDDED: &str = "DBRST108";
24    // DBRST109 is no longer used (LimitNoOrderError)
25    // DBRST110 is no longer used (OffLimitsChangesError)
26    pub const GUC_HEADERS_ERROR: &str = "DBRST111";
27    pub const GUC_STATUS_ERROR: &str = "DBRST112";
28    // DBRST113 is no longer used (BinaryFieldError)
29    pub const PUT_LIMIT_NOT_ALLOWED: &str = "DBRST114";
30    pub const PUT_MATCHING_PK_ERROR: &str = "DBRST115";
31    pub const SINGULARITY_ERROR: &str = "DBRST116";
32    pub const UNSUPPORTED_METHOD: &str = "DBRST117";
33    pub const RELATED_ORDER_NOT_TO_ONE: &str = "DBRST118";
34    // DBRST119 is unused
35    pub const UNACCEPTABLE_FILTER: &str = "DBRST120";
36    pub const DBRST_PARSE_ERROR: &str = "DBRST121";
37    pub const INVALID_PREFERENCES: &str = "DBRST122";
38    pub const AGGREGATES_NOT_ALLOWED: &str = "DBRST123";
39    pub const MAX_AFFECTED_VIOLATION: &str = "DBRST124";
40    pub const INVALID_RESOURCE_PATH: &str = "DBRST125";
41    pub const OPENAPI_DISABLED: &str = "DBRST126";
42    pub const NOT_IMPLEMENTED: &str = "DBRST127";
43    pub const MAX_AFFECTED_RPC_VIOLATION: &str = "DBRST128";
44
45    // Legacy/alternative codes for compatibility
46    pub const PARSE_ERROR: &str = "DBRST101"; // Alias for INVALID_RPC_METHOD
47    pub const INVALID_CONTENT_TYPE: &str = "DBRST103"; // Alias for INVALID_RANGE
48    pub const INVALID_PREFERENCE: &str = "DBRST104"; // Legacy
49    pub const INVALID_FILTER_OPERATOR: &str = "DBRST105"; // Alias for INVALID_FILTERS
50    pub const SCHEMA_NOT_FOUND: &str = "DBRST106"; // Alias for UNACCEPTABLE_SCHEMA
51    pub const INVALID_SPREAD_COLUMN: &str = "DBRST107"; // Alias for MEDIA_TYPE_ERROR
52    pub const AMBIGUOUS_EMBEDDING: &str = "DBRST108"; // Alias for NOT_EMBEDDED
53    pub const INVALID_EMBEDDING: &str = "DBRST109"; // Legacy
54    pub const INVALID_MEDIA_HANDLER: &str = "DBRST112"; // Alias for GUC_STATUS_ERROR
55    pub const MEDIA_TYPE_MISMATCH: &str = "DBRST113"; // Legacy
56    pub const URI_TOO_LONG: &str = "DBRST114"; // Alias for PUT_LIMIT_NOT_ALLOWED
57    pub const INVALID_AGGREGATE: &str = "DBRST115"; // Alias for PUT_MATCHING_PK_ERROR
58}
59
60/// Schema cache errors (200-299)
61pub mod schema {
62    pub const RELATIONSHIP_NOT_FOUND: &str = "DBRST200"; // NoRelBetween
63    pub const AMBIGUOUS_RELATIONSHIP: &str = "DBRST201"; // AmbiguousRelBetween
64    pub const FUNCTION_NOT_FOUND: &str = "DBRST202"; // NoRpc
65    pub const AMBIGUOUS_FUNCTION: &str = "DBRST203"; // AmbiguousRpc
66    pub const COLUMN_NOT_FOUND: &str = "DBRST204"; // ColumnNotFound
67    pub const TABLE_NOT_FOUND: &str = "DBRST205"; // TableNotFound
68    pub const SCHEMA_CACHE_NOT_READY: &str = "DBRST204"; // Legacy alias
69}
70
71/// Authentication errors (300-399)
72pub mod auth {
73    pub const SECRET_MISSING: &str = "DBRST300";
74    pub const JWT_ERROR: &str = "DBRST301";
75    pub const NO_ANON_ROLE: &str = "DBRST302";
76    pub const CLAIMS_ERROR: &str = "DBRST303";
77}
78
79/// Request/action errors (400-499)
80pub mod action {
81    pub const NOT_INSERTABLE: &str = "DBRST400";
82    pub const NOT_UPDATABLE: &str = "DBRST401";
83    pub const NOT_DELETABLE: &str = "DBRST402";
84    pub const SINGLE_OBJECT_EXPECTED: &str = "DBRST405";
85    pub const MISSING_PAYLOAD: &str = "DBRST406";
86    pub const INVALID_PAYLOAD: &str = "DBRST407";
87    pub const NO_PRIMARY_KEY: &str = "DBRST408";
88    pub const PUT_INCOMPLETE: &str = "DBRST409";
89}
90
91/// Database errors (500-599)
92pub mod database {
93    pub const DB_ERROR: &str = "DBRST500";
94    pub const FK_VIOLATION: &str = "DBRST501";
95    pub const UNIQUE_VIOLATION: &str = "DBRST502";
96    pub const CHECK_VIOLATION: &str = "DBRST503";
97    pub const MAX_ROWS_EXCEEDED: &str = "DBRST504";
98    pub const NOT_NULL_VIOLATION: &str = "DBRST505";
99    pub const EXCLUSION_VIOLATION: &str = "DBRST506";
100    pub const RAISED_EXCEPTION: &str = "DBRST507";
101    pub const DBRST_RAISE: &str = "DBRST508";
102}
103
104/// Internal errors
105pub mod internal {
106    pub const INTERNAL_ERROR: &str = "DBRST999";
107}