#[repr(u32)]pub enum ApiErrorCode {
MalformedRequest = 40_010_000,
InvalidCredentials = 40_110_000,
Forbidden = 40_310_000,
NotFound = 40_410_000,
UnprocessableEntity = 42_210_000,
RateLimitExceeded = 42_910_000,
InternalServerError = 50_010_000,
Unknown = 0,
}Expand description
Alpaca-specific API error codes.
These codes are returned by the Alpaca API to indicate specific error conditions.
Variants§
MalformedRequest = 40_010_000
Malformed request body or parameters.
InvalidCredentials = 40_110_000
Invalid or missing authentication credentials.
Forbidden = 40_310_000
Access forbidden for this resource.
NotFound = 40_410_000
Requested resource not found.
UnprocessableEntity = 42_210_000
Request validation failed.
RateLimitExceeded = 42_910_000
Rate limit exceeded.
InternalServerError = 50_010_000
Internal server error.
Unknown = 0
Unknown error code.
Implementations§
Source§impl ApiErrorCode
impl ApiErrorCode
Sourcepub fn from_code(code: u32) -> Self
pub fn from_code(code: u32) -> Self
Creates an ApiErrorCode from a numeric code.
Examples found in repository?
examples/base_error_handling.rs (line 58)
45fn demonstrate_error_codes() {
46 // Convert numeric codes to typed error codes
47 let codes = [
48 (40010000, "Malformed Request"),
49 (40110000, "Invalid Credentials"),
50 (40310000, "Forbidden"),
51 (40410000, "Not Found"),
52 (42210000, "Unprocessable Entity"),
53 (42910000, "Rate Limit Exceeded"),
54 (50010000, "Internal Server Error"),
55 ];
56
57 for (code, description) in codes {
58 let error_code = ApiErrorCode::from_code(code);
59 println!(
60 " Code {}: {} (client_error={}, server_error={})",
61 code,
62 description,
63 error_code.is_client_error(),
64 error_code.is_server_error()
65 );
66 }
67}Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Returns true if this is a client error (4xx).
Examples found in repository?
examples/base_error_handling.rs (line 63)
45fn demonstrate_error_codes() {
46 // Convert numeric codes to typed error codes
47 let codes = [
48 (40010000, "Malformed Request"),
49 (40110000, "Invalid Credentials"),
50 (40310000, "Forbidden"),
51 (40410000, "Not Found"),
52 (42210000, "Unprocessable Entity"),
53 (42910000, "Rate Limit Exceeded"),
54 (50010000, "Internal Server Error"),
55 ];
56
57 for (code, description) in codes {
58 let error_code = ApiErrorCode::from_code(code);
59 println!(
60 " Code {}: {} (client_error={}, server_error={})",
61 code,
62 description,
63 error_code.is_client_error(),
64 error_code.is_server_error()
65 );
66 }
67}Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns true if this is a server error (5xx).
Examples found in repository?
examples/base_error_handling.rs (line 64)
45fn demonstrate_error_codes() {
46 // Convert numeric codes to typed error codes
47 let codes = [
48 (40010000, "Malformed Request"),
49 (40110000, "Invalid Credentials"),
50 (40310000, "Forbidden"),
51 (40410000, "Not Found"),
52 (42210000, "Unprocessable Entity"),
53 (42910000, "Rate Limit Exceeded"),
54 (50010000, "Internal Server Error"),
55 ];
56
57 for (code, description) in codes {
58 let error_code = ApiErrorCode::from_code(code);
59 println!(
60 " Code {}: {} (client_error={}, server_error={})",
61 code,
62 description,
63 error_code.is_client_error(),
64 error_code.is_server_error()
65 );
66 }
67}Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is retryable.
Trait Implementations§
Source§impl Clone for ApiErrorCode
impl Clone for ApiErrorCode
Source§fn clone(&self) -> ApiErrorCode
fn clone(&self) -> ApiErrorCode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ApiErrorCode
impl Debug for ApiErrorCode
Source§impl<'de> Deserialize<'de> for ApiErrorCode
impl<'de> Deserialize<'de> for ApiErrorCode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ApiErrorCode
impl Display for ApiErrorCode
Source§impl Error for ApiErrorCode
impl Error for ApiErrorCode
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl PartialEq for ApiErrorCode
impl PartialEq for ApiErrorCode
Source§impl Serialize for ApiErrorCode
impl Serialize for ApiErrorCode
impl Copy for ApiErrorCode
impl Eq for ApiErrorCode
impl StructuralPartialEq for ApiErrorCode
Auto Trait Implementations§
impl Freeze for ApiErrorCode
impl RefUnwindSafe for ApiErrorCode
impl Send for ApiErrorCode
impl Sync for ApiErrorCode
impl Unpin for ApiErrorCode
impl UnwindSafe for ApiErrorCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more