nacos_sdk/api/
error.rs

1// Licensed to the Apache Software Foundation (ASF) under one or more
2// contributor license agreements.  See the NOTICE file distributed with
3// this work for additional information regarding copyright ownership.
4// The ASF licenses this file to You under the Apache License, Version 2.0
5// (the "License"); you may not use this file except in compliance with
6// the License.  You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17use tower::BoxError;
18
19/// Nacos Sdk Rust Result.
20pub type Result<T> = std::result::Result<T, Error>;
21
22/// Nacos Sdk Rust Error.
23#[derive(Debug, thiserror::Error)]
24pub enum Error {
25    #[error("Serialization failed: {0}")]
26    Serialization(#[from] serde_json::Error),
27
28    #[error("get result failed: {0}")]
29    ErrResult(String),
30
31    #[error("param:{0} with error_message:{1}")]
32    InvalidParam(String, String),
33
34    #[error("request_id:{0:?} ret_code:{1} error_code:{2} message:{3:?}")]
35    ErrResponse(Option<String>, i32, i32, Option<String>),
36
37    /// Config not found.
38    #[cfg(feature = "config")]
39    #[error("config not found: {0}")]
40    ConfigNotFound(String),
41
42    /// Config query conflict, it is being modified, please try later.
43    #[cfg(feature = "config")]
44    #[error("config query conflict: {0}")]
45    ConfigQueryConflict(String),
46
47    #[error("remote client shutdown failed: {0}")]
48    ClientShutdown(String),
49
50    #[error("remote client unhealthy failed: {0}")]
51    ClientUnhealthy(String),
52
53    #[error("tonic grpc transport error: {0}")]
54    TonicGrpcTransport(#[from] tonic::transport::Error),
55
56    #[error("tonic grpc status error: {0}")]
57    TonicGrpcStatus(#[from] tonic::Status),
58
59    #[error("grpc request error: {0}")]
60    GrpcBufferRequest(#[from] BoxError),
61
62    #[error("no available server")]
63    NoAvailableServer,
64
65    #[error("Wrong server address: {0}")]
66    WrongServerAddress(String),
67
68    #[error("Exceeded maximum retry attempts: {0}")]
69    MaxRetriesExceeded(u32),
70}