mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-22 22:20:02 +00:00
feat: add trigger-related error code (#6419)
This commit is contained in:
@@ -119,6 +119,11 @@ pub enum StatusCode {
|
||||
FlowAlreadyExists = 8000,
|
||||
FlowNotFound = 8001,
|
||||
// ====== End of flow related status code =====
|
||||
|
||||
// ====== Begin of trigger related status code =====
|
||||
TriggerAlreadyExists = 9000,
|
||||
TriggerNotFound = 9001,
|
||||
// ====== End of trigger related status code =====
|
||||
}
|
||||
|
||||
impl StatusCode {
|
||||
@@ -155,6 +160,8 @@ impl StatusCode {
|
||||
| StatusCode::RegionNotFound
|
||||
| StatusCode::FlowAlreadyExists
|
||||
| StatusCode::FlowNotFound
|
||||
| StatusCode::TriggerAlreadyExists
|
||||
| StatusCode::TriggerNotFound
|
||||
| StatusCode::RegionReadonly
|
||||
| StatusCode::TableColumnNotFound
|
||||
| StatusCode::TableColumnExists
|
||||
@@ -198,6 +205,8 @@ impl StatusCode {
|
||||
| StatusCode::PlanQuery
|
||||
| StatusCode::FlowAlreadyExists
|
||||
| StatusCode::FlowNotFound
|
||||
| StatusCode::TriggerAlreadyExists
|
||||
| StatusCode::TriggerNotFound
|
||||
| StatusCode::RegionNotReady
|
||||
| StatusCode::RegionBusy
|
||||
| StatusCode::RegionReadonly
|
||||
@@ -281,12 +290,14 @@ pub fn status_to_tonic_code(status_code: StatusCode) -> Code {
|
||||
| StatusCode::TableColumnExists
|
||||
| StatusCode::RegionAlreadyExists
|
||||
| StatusCode::DatabaseAlreadyExists
|
||||
| StatusCode::TriggerAlreadyExists
|
||||
| StatusCode::FlowAlreadyExists => Code::AlreadyExists,
|
||||
StatusCode::TableNotFound
|
||||
| StatusCode::RegionNotFound
|
||||
| StatusCode::TableColumnNotFound
|
||||
| StatusCode::DatabaseNotFound
|
||||
| StatusCode::UserNotFound
|
||||
| StatusCode::TriggerNotFound
|
||||
| StatusCode::FlowNotFound => Code::NotFound,
|
||||
StatusCode::TableUnavailable
|
||||
| StatusCode::StorageUnavailable
|
||||
|
||||
@@ -807,6 +807,8 @@ pub fn status_code_to_http_status(status_code: &StatusCode) -> HttpStatusCode {
|
||||
| StatusCode::TableColumnNotFound
|
||||
| StatusCode::PlanQuery
|
||||
| StatusCode::DatabaseAlreadyExists
|
||||
| StatusCode::TriggerAlreadyExists
|
||||
| StatusCode::TriggerNotFound
|
||||
| StatusCode::FlowNotFound
|
||||
| StatusCode::FlowAlreadyExists => HttpStatusCode::BAD_REQUEST,
|
||||
|
||||
|
||||
@@ -369,5 +369,7 @@ fn mysql_error_kind(status_code: &StatusCode) -> ErrorKind {
|
||||
StatusCode::RateLimited => ErrorKind::ER_TOO_MANY_CONCURRENT_TRXS,
|
||||
StatusCode::FlowAlreadyExists => ErrorKind::ER_TABLE_EXISTS_ERROR,
|
||||
StatusCode::FlowNotFound => ErrorKind::ER_NO_SUCH_TABLE,
|
||||
StatusCode::TriggerAlreadyExists => ErrorKind::ER_TABLE_EXISTS_ERROR,
|
||||
StatusCode::TriggerNotFound => ErrorKind::ER_NO_SUCH_TABLE,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,11 +389,13 @@ impl From<StatusCode> for PgErrorCode {
|
||||
// ====== End of SQL & query related status code ===========
|
||||
|
||||
// ====== Begin of catalog & flow related status code =====
|
||||
StatusCode::TableNotFound | StatusCode::FlowNotFound | StatusCode::RegionNotFound => {
|
||||
PgErrorCode::Ec42P01
|
||||
}
|
||||
StatusCode::TableNotFound
|
||||
| StatusCode::FlowNotFound
|
||||
| StatusCode::RegionNotFound
|
||||
| StatusCode::TriggerNotFound => PgErrorCode::Ec42P01,
|
||||
StatusCode::TableAlreadyExists
|
||||
| StatusCode::FlowAlreadyExists
|
||||
| StatusCode::TriggerAlreadyExists
|
||||
| StatusCode::RegionAlreadyExists => PgErrorCode::Ec42P07,
|
||||
|
||||
StatusCode::TableColumnNotFound => PgErrorCode::Ec42703,
|
||||
|
||||
Reference in New Issue
Block a user