smolder_core/error.rs
1//! Errors returned by the core client/session layer.
2
3use crate::auth::AuthError;
4use smolder_proto::smb::smb2::Command;
5use smolder_proto::smb::ProtocolError;
6use thiserror::Error;
7
8/// Errors returned while driving SMB requests over a transport.
9#[derive(Debug, Error)]
10pub enum CoreError {
11 /// The transport returned an I/O failure.
12 #[error("transport error")]
13 Io(#[from] std::io::Error),
14 /// The local filesystem or local stream returned an I/O failure.
15 #[error("local I/O error")]
16 LocalIo(std::io::Error),
17 /// Packet encoding or decoding failed.
18 #[error("protocol error")]
19 Protocol(#[from] ProtocolError),
20 /// Authentication token processing failed.
21 #[error("authentication error")]
22 Auth(#[from] AuthError),
23 /// The server responded with a different command than expected.
24 #[error("unexpected response command: expected {expected:?}, got {actual:?}")]
25 UnexpectedCommand {
26 /// The command that was sent.
27 expected: Command,
28 /// The command returned by the peer.
29 actual: Command,
30 },
31 /// The server returned a status code that the caller did not allow.
32 #[error("unexpected status code 0x{status:08x} for {command:?}")]
33 UnexpectedStatus {
34 /// The command being processed.
35 command: Command,
36 /// The returned NTSTATUS value.
37 status: u32,
38 },
39 /// The response was structurally valid but semantically unusable.
40 #[error("invalid response: {0}")]
41 InvalidResponse(&'static str),
42 /// The caller supplied invalid input to a high-level API.
43 #[error("invalid input: {0}")]
44 InvalidInput(&'static str),
45 /// The caller supplied an invalid SMB share path or UNC path.
46 #[error("invalid path: {0}")]
47 PathInvalid(&'static str),
48 /// The requested operation is valid but not supported by the negotiated session or server.
49 #[error("unsupported: {0}")]
50 Unsupported(&'static str),
51 /// A remote RPC or service-control operation returned a failure code.
52 #[error("remote {operation} failed with 0x{code:08x}")]
53 RemoteOperation {
54 /// Operation label.
55 operation: &'static str,
56 /// Returned status or Win32 error code.
57 code: u32,
58 },
59 /// The requested operation exceeded its timeout budget.
60 #[error("operation timed out: {0}")]
61 Timeout(&'static str),
62}