-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathrejection.rs
More file actions
45 lines (39 loc) · 1.69 KB
/
rejection.rs
File metadata and controls
45 lines (39 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::rejection::MissingContentTypeReason;
use aws_smithy_runtime_api::http::HttpError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ResponseRejection {
#[error("error building HTTP response: {0}")]
Build(#[from] aws_smithy_types::error::operation::BuildError),
#[error("error serializing JSON-encoded body: {0}")]
Serialization(#[from] aws_smithy_types::error::operation::SerializationError),
#[error("error building HTTP response: {0}")]
HttpBuild(#[from] http::Error),
}
#[derive(Debug, Error)]
pub enum RequestRejection {
#[error("error converting non-streaming body to bytes: {0}")]
BufferHttpBodyBytes(crate::Error),
#[error("request contains invalid value for `Accept` header")]
NotAcceptable,
#[error("expected `Content-Type` header not found: {0}")]
MissingContentType(#[from] MissingContentTypeReason),
#[error("error deserializing request HTTP body as JSON: {0}")]
JsonDeserialize(#[from] aws_smithy_json::deserialize::error::DeserializeError),
#[error("request does not adhere to modeled constraints: {0}")]
ConstraintViolation(String),
/// Typically happens when the request has headers that are not valid UTF-8.
#[error("failed to convert request: {0}")]
HttpConversion(#[from] HttpError),
}
impl From<std::convert::Infallible> for RequestRejection {
fn from(_err: std::convert::Infallible) -> Self {
match _err {}
}
}
convert_to_request_rejection!(hyper::Error, BufferHttpBodyBytes);
convert_to_request_rejection!(Box<dyn std::error::Error + Send + Sync + 'static>, BufferHttpBodyBytes);