aws: improve error message logs
The Display
and Debug
trait for the AWS error messages are not very useful.
-
Display
only prints the high level error, e.g.: "service error". -
Debug
prints all the fields in the error stack, resulting in hard to read messages with redudant or unnecessary information. E.g.:
ServiceError(ServiceError { source: BadRequestException(BadRequestException { message: Some("1 validation error detected: Value 'test' at 'languageCode' failed to satisfy constraint: Member must satisfy enum value set: [ar-AE, zh-HK, en-US, ar-SA, zh-CN, fi-FI, pl-PL, no-NO, nl-NL, pt-PT, es-ES, th-TH, de-DE, it-IT, fr-FR, ko-KR, hi-IN, en-AU, pt-BR, sv-SE, ja-JP, ca-ES, es-US, fr-CA, en-GB]"), meta: ErrorMetadata { code: Some("BadRequestException"), message: Some("1 validation error detected: Value 'test' at 'languageCode' failed to satisfy constraint: Member must satisfy enum value set: [ar-AE, zh-HK, en-US, ar-SA, zh-CN, fi-FI, pl-PL, no-NO, nl-NL, pt-PT, es-ES, th-TH, de-DE, it-IT, fr-FR, ko-KR, hi-IN, en-AU, pt-BR, sv-SE, ja-JP, ca-ES, es-US, fr-CA, en-GB]"), extras: Some({"aws_request_id": "1b8bbafd-5b71-4ba5-8676-28432381e6a9"}) } }), raw: Response { status: StatusCode(400), headers: Headers { headers: {"x-amzn-requestid": HeaderValue { _private: H0("1b8bbafd-5b71-4ba5-8676-28432381e6a9") }, "x-amzn-errortype": HeaderValue { _private: H0("BadRequestException:http://internal.amazon.com/coral/com.amazonaws.transcribe.streaming/") }, "date": HeaderValue { _private: H0("Tue, 26 Mar 2024 17:41:31 GMT") }, "content-type": HeaderValue { _private: H0("application/x-amz-json-1.1") }, "content-length": HeaderValue { _private: H0("315") }} }, body: SdkBody { inner: Once(Some(b"{"Message":"1 validation error detected: Value 'test' at 'languageCode' failed to satisfy constraint: Member must satisfy enum value set: [ar-AE, zh-HK, en-US, ar-SA, zh-CN, fi-FI, pl-PL, no-NO, nl-NL, pt-PT, es-ES, th-TH, de-DE, it-IT, fr-FR, ko-KR, hi-IN, en-AU, pt-BR, sv-SE, ja-JP, ca-ES, es-US, fr-CA, en-GB]"}")), retryable: true }, extensions: Extensions { extensions_02x: Extensions, extensions_1x: Extensions } } })
This commit adopts the most informative and concise solution I could come up with to log AWS errors. With the above error case, this results in:
service error: Error { code: "BadRequestException", message: "1 validation error detected: Value 'test' at 'languageCode' failed to satisfy constraint: Member must satisfy enum value set: [ar-AE, zh-HK, en-US, ar-SA, zh-CN, fi-FI, pl-PL, no-NO, nl-NL, pt-PT, es-ES, th-TH, de-DE, it-IT, fr-FR, ko-KR, hi-IN, en-AU, pt-BR, sv-SE, ja-JP, ca-ES, es-US, fr-CA, en-GB]", aws_request_id: "a40a32a8-7b0b-4228-a348-f8502087a9f0" }