Skip to content

Commit

Permalink
May 18th Release v0.0.4-alpha, smithy-rs v0.9 (awslabs#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh authored May 18, 2021
1 parent 140fe74 commit 7683f75
Show file tree
Hide file tree
Showing 130 changed files with 88,391 additions and 34,240 deletions.
2 changes: 1 addition & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = [
"dynamodb","kinesis","apigateway","qldb","polly","kms","qldbsession","secretsmanager","smithy-types","smithy-http","smithy-http-tower","protocol-test-helpers","aws-auth","aws-endpoint","aws-types","aws-hyper","aws-sig-auth","aws-http","examples/dynamo-delete-item","examples/dynamo-list-items","examples/kinesis-list-streams","examples/secretsmanager-create-secret","examples/secretsmanager-get-secret-value","examples/polly-describe-voices","examples/secretsmanager-helloworld","examples/polly-synthesize-speech","examples/dynamo-create-table","examples/polly-put-lexicon","examples/dynamo-list-tables","examples/qldbsession-helloworld","examples/dynamo-helloworld","examples/kinesis-create-stream","examples/polly-helloworld","examples/secretsmanager-list-secrets","examples/polly-list-lexicons","examples/kms-helloworld","examples/kinesis-describe-stream","examples/dynamo-delete-table","examples/qldb-list-ledgers","examples/dynamo-add-item","examples/kinesis-delete-stream","examples/dynamo-movies","examples/kinesis-put-record"
"dynamodb","kinesis","lambda","apigateway","qldb","polly","kms","qldbsession","secretsmanager","smithy-types","smithy-http","smithy-http-tower","protocol-test-helpers","aws-auth","aws-endpoint","aws-types","aws-hyper","aws-sig-auth","aws-http","examples/dynamo-delete-item","examples/lambda-list-functions","examples/dynamo-list-items","examples/kinesis-list-streams","examples/secretsmanager-create-secret","examples/secretsmanager-get-secret-value","examples/polly-describe-voices","examples/secretsmanager-helloworld","examples/polly-synthesize-speech","examples/dynamo-create-table","examples/polly-put-lexicon","examples/dynamo-list-tables","examples/qldbsession-helloworld","examples/dynamo-helloworld","examples/kinesis-create-stream","examples/polly-helloworld","examples/secretsmanager-list-secrets","examples/polly-list-lexicons","examples/lambda-invoke-function","examples/kms-helloworld","examples/kinesis-describe-stream","examples/dynamo-delete-table","examples/qldb-list-ledgers","examples/dynamo-add-item","examples/kinesis-delete-stream","examples/dynamo-movies","examples/kinesis-put-record"
]
4 changes: 2 additions & 2 deletions sdk/apigateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ version = "0.2"
path = "..//aws-http"
[dependencies.aws-sig-auth]
path = "..//aws-sig-auth"
[dependencies.bytes]
version = "1"
[dependencies.serde_json]
version = "1"
features = ["float_roundtrip"]
[dependencies.bytes]
version = "1"
[features]
client = ["aws-hyper"]
rustls = ["aws-hyper/rustls"]
Expand Down
26 changes: 26 additions & 0 deletions sdk/apigateway/src/aws_json_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use http::header::ToStrError;

// currently only used by AwsJson
#[allow(unused)]
pub fn is_error<B>(response: &http::Response<B>) -> bool {
!response.status().is_success()
}
Expand Down Expand Up @@ -50,6 +52,8 @@ pub fn parse_generic_error<B>(
.map(|s| sanitize_error_code(s).to_string());
let message = body
.get("message")
.or_else(|| body.get("Message"))
.or_else(|| body.get("errorMessage"))
.and_then(|v| v.as_str())
.map(|s| s.to_string());
let request_id = response
Expand Down Expand Up @@ -135,4 +139,26 @@ mod test {
"FooError"
);
}

// services like lambda use an alternate `Message` instead of `message`
#[test]
fn alternative_error_message_names() {
let response = http::Response::builder()
.header("x-amzn-errortype", "ResourceNotFoundException")
.body(json!({
"Type": "User",
"Message": "Functions from 'us-west-2' are not reachable from us-east-1"
}))
.unwrap();
assert_eq!(
parse_generic_error(&response, response.body()),
Error {
code: Some("ResourceNotFoundException".to_string()),
message: Some(
"Functions from 'us-west-2' are not reachable from us-east-1".to_string()
),
request_id: None,
}
)
}
}
Loading

0 comments on commit 7683f75

Please sign in to comment.