Skip to main content

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
17/// Nacos Sdk Rust Result.
18pub type Result<T> = std::result::Result<T, Error>;
19
20/// Nacos Sdk Rust Error.
21#[non_exhaustive]
22#[derive(Debug, thiserror::Error)]
23pub enum Error {
24    #[error("Serialization failed: {0}")]
25    Serialization(#[from] serde_json::Error),
26
27    #[error("get result failed: {0}")]
28    ErrResult(String),
29
30    #[error("param:{0} with error_message:{1}")]
31    InvalidParam(String, String),
32
33    #[error("request_id:{0:?} ret_code:{1} error_code:{2} message:{3:?}")]
34    ErrResponse(Option<String>, i32, i32, Option<String>),
35
36    /// Config not found.
37    #[cfg(feature = "config")]
38    #[error("config not found: {0}")]
39    ConfigNotFound(String),
40
41    /// Config query conflict, it is being modified, please try later.
42    #[cfg(feature = "config")]
43    #[error("config query conflict: {0}")]
44    ConfigQueryConflict(String),
45
46    #[error("remote client shutdown failed: {0}")]
47    ClientShutdown(String),
48
49    #[error("remote client unhealthy failed: {0}")]
50    ClientUnhealthy(String),
51
52    #[error("tonic grpc transport error: {0}")]
53    TonicGrpcTransport(#[from] tonic::transport::Error),
54
55    #[error("tonic grpc status error: {0}")]
56    TonicGrpcStatus(#[from] tonic::Status),
57
58    #[error("grpc request error: {0}")]
59    GrpcBufferRequest(#[from] tower::BoxError),
60
61    #[error("no available server")]
62    NoAvailableServer,
63
64    #[error("Wrong server address: {0}")]
65    WrongServerAddress(String),
66
67    #[deprecated]
68    #[allow(unused)]
69    #[error("Exceeded maximum retry attempts: {0}")]
70    MaxRetriesExceeded(u32),
71}