mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-17 05:20:37 +00:00
fix: adjust status code to http error code map (#3601)
* fix: adjust status code to http error code map Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * update integration test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -84,6 +84,7 @@ impl IntoResponse for ErrorResponse {
|
||||
let status = StatusCode::from_u32(code).unwrap_or(StatusCode::Unknown);
|
||||
let status_code = match status {
|
||||
StatusCode::Success | StatusCode::Cancelled => HttpStatusCode::OK,
|
||||
|
||||
StatusCode::Unsupported
|
||||
| StatusCode::InvalidArguments
|
||||
| StatusCode::InvalidSyntax
|
||||
@@ -94,7 +95,9 @@ impl IntoResponse for ErrorResponse {
|
||||
| StatusCode::RegionNotFound
|
||||
| StatusCode::DatabaseNotFound
|
||||
| StatusCode::TableNotFound
|
||||
| StatusCode::TableColumnNotFound => HttpStatusCode::BAD_REQUEST,
|
||||
| StatusCode::TableColumnNotFound
|
||||
| StatusCode::PlanQuery => HttpStatusCode::BAD_REQUEST,
|
||||
|
||||
StatusCode::PermissionDenied
|
||||
| StatusCode::AuthHeaderNotFound
|
||||
| StatusCode::InvalidAuthHeader
|
||||
@@ -102,16 +105,19 @@ impl IntoResponse for ErrorResponse {
|
||||
| StatusCode::UnsupportedPasswordType
|
||||
| StatusCode::UserPasswordMismatch
|
||||
| StatusCode::RegionReadonly => HttpStatusCode::UNAUTHORIZED,
|
||||
|
||||
StatusCode::AccessDenied => HttpStatusCode::FORBIDDEN,
|
||||
|
||||
StatusCode::RateLimited => HttpStatusCode::TOO_MANY_REQUESTS,
|
||||
|
||||
StatusCode::RegionNotReady
|
||||
| StatusCode::RegionBusy
|
||||
| StatusCode::StorageUnavailable => HttpStatusCode::SERVICE_UNAVAILABLE,
|
||||
|
||||
StatusCode::Internal
|
||||
| StatusCode::Unexpected
|
||||
| StatusCode::Unknown
|
||||
| StatusCode::RegionNotReady
|
||||
| StatusCode::RegionBusy
|
||||
| StatusCode::RateLimited
|
||||
| StatusCode::StorageUnavailable
|
||||
| StatusCode::RuntimeResourcesExhausted
|
||||
| StatusCode::PlanQuery
|
||||
| StatusCode::EngineExecuteQuery => HttpStatusCode::INTERNAL_SERVER_ERROR,
|
||||
};
|
||||
(status_code, resp).into_response()
|
||||
|
||||
@@ -252,7 +252,7 @@ pub async fn test_sql_api(store_type: StorageType) {
|
||||
.get("/v1/sql?sql=select cpu, ts from demo limit 1;select cpu, ts from demo2 where ts > 0;")
|
||||
.send()
|
||||
.await;
|
||||
assert_eq!(res.status(), StatusCode::INTERNAL_SERVER_ERROR);
|
||||
assert_eq!(res.status(), StatusCode::BAD_REQUEST);
|
||||
|
||||
let body = serde_json::from_str::<ErrorResponse>(&res.text().await).unwrap();
|
||||
// TODO(shuiyisong): fix this when return source err msg to client side
|
||||
|
||||
Reference in New Issue
Block a user