1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Defines mapping from service errors to service error codes.
//!
//! ### Common Service Errors
//! | Error | Service Error Code |
//! |---|---|
//! | `Unexpected Error` | E0000 |
//! | [sqlx::Error] | E0001 |
//! | [serde_json::error::Error] | E0002 |
//! | [crate::persistence::RepositoryError]| E0003 |
//! | [anyhow::Error] | E0004 and E0005 |
//! | [crate::security::AuthorizationError] | E0006 |
//! | [crate::security::AccessForbiddenError] | E0007 |
//
//! ### Error cases of [sqlx::Error::Database]
//! | Postgres Error Code | Error Name | Serivce Error Code |
//! |---|---|---|
//! | Any | generic database error | E0100 |
//! | 23000 | integrity_constraint_violation | E0101 |
//! | 23001 | restrict_violation | E0102 |
//! | 23502 | not_null_violation | E0103 |
//! | 23503 | foreign_key_violation | E0104 |
//! | 23505 | unique_violation | E0105 |
//! | 23514 | check_violation | E0106 |
//! | 23P01 | exclusion_violation | E0107 |
pub static AUTHORIZATION_ERROR: &str = "E0006";
pub static ACCESS_FORBIDDEN_ERROR: &str = "E0007";
pub static GENERIC_ERROR: &str = "E0000";
pub static NOT_FOUND_ERROR: &str = "E0001";
pub static DATA_FORMAT_ERROR: &str = "E0002";
pub static CONTOLLER_ERROR: &str = "E0004";
pub static PERSISTENCE_ERROR: &str = "E0003";
pub static SERVICE_ERROR: &str = "E0005";
pub static GENERIC_DB_ERROR: &str = "E0100";
pub static SCHEMA_VIOLATION_ERROR: & = &;