neo3/neo_fs/error.rs
1// Copyright (c) 2023-2025 R3E Network
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14//! # NeoFS Error Handling
15//!
16//! This module provides error types for NeoFS operations.
17
18use std::fmt;
19use thiserror::Error;
20
21/// Errors that can occur during NeoFS operations
22#[derive(Error, Debug)]
23pub enum NeoFSError {
24 /// Connection error
25 #[error("Connection error: {0}")]
26 ConnectionError(String),
27
28 /// Authentication error
29 #[error("Authentication error: {0}")]
30 AuthenticationError(String),
31
32 /// Container error
33 #[error("Container error: {0}")]
34 ContainerError(String),
35
36 /// Object error
37 #[error("Object error: {0}")]
38 ObjectError(String),
39
40 /// Access control error
41 #[error("Access control error: {0}")]
42 ACLError(String),
43
44 /// Serialization/deserialization error
45 #[error("Serialization error: {0}")]
46 SerializationError(String),
47
48 /// Permission denied
49 #[error("Permission denied: {0}")]
50 PermissionDenied(String),
51
52 /// Resource not found
53 #[error("Resource not found: {0}")]
54 NotFound(String),
55
56 /// Invalid argument
57 #[error("Invalid argument: {0}")]
58 InvalidArgument(String),
59
60 /// Operation timeout
61 #[error("Operation timeout: {0}")]
62 Timeout(String),
63
64 /// Internal error
65 #[error("Internal error: {0}")]
66 InternalError(String),
67
68 /// Conversion error
69 #[error("Conversion error: {0}")]
70 ConversionError(String),
71
72 /// Not implemented
73 #[error("Not implemented: {0}")]
74 NotImplemented(String),
75
76 /// Generic IO error
77 #[error("IO error: {0}")]
78 IOError(#[from] std::io::Error),
79
80 /// Unexpected response
81 #[error("Unexpected response: {0}")]
82 UnexpectedResponse(String),
83}
84
85/// Result type for NeoFS operations
86pub type NeoFSResult<T> = std::result::Result<T, NeoFSError>;