Struct aws_sdk_comprehend::error::DetectSentimentError
source · #[non_exhaustive]pub struct DetectSentimentError {
pub kind: DetectSentimentErrorKind,
/* private fields */
}Expand description
Error type for the DetectSentiment operation.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: DetectSentimentErrorKindKind of error that occurred.
Implementations§
source§impl DetectSentimentError
impl DetectSentimentError
sourcepub fn new(kind: DetectSentimentErrorKind, meta: Error) -> Self
pub fn new(kind: DetectSentimentErrorKind, meta: Error) -> Self
Creates a new DetectSentimentError.
sourcepub fn unhandled(err: impl Into<Box<dyn Error + Send + Sync + 'static>>) -> Self
pub fn unhandled(err: impl Into<Box<dyn Error + Send + Sync + 'static>>) -> Self
Creates the DetectSentimentError::Unhandled variant from any error type.
Examples found in repository?
3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942
pub fn parse_detect_sentiment_error(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<crate::output::DetectSentimentOutput, crate::error::DetectSentimentError> {
let generic = crate::json_deser::parse_http_generic_error(response)
.map_err(crate::error::DetectSentimentError::unhandled)?;
let error_code = match generic.code() {
Some(code) => code,
None => return Err(crate::error::DetectSentimentError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"InternalServerException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::InternalServerException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::internal_server_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_internal_server_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"InvalidRequestException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::InvalidRequestException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::invalid_request_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_invalid_request_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"TextSizeLimitExceededException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::TextSizeLimitExceededException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::error::text_size_limit_exceeded_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_text_size_limit_exceeded_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"UnsupportedLanguageException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::UnsupportedLanguageException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::error::unsupported_language_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_unsupported_language_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
_ => crate::error::DetectSentimentError::generic(generic),
})
}sourcepub fn generic(err: Error) -> Self
pub fn generic(err: Error) -> Self
Creates the DetectSentimentError::Unhandled variant from a aws_smithy_types::Error.
Examples found in repository?
3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942
pub fn parse_detect_sentiment_error(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<crate::output::DetectSentimentOutput, crate::error::DetectSentimentError> {
let generic = crate::json_deser::parse_http_generic_error(response)
.map_err(crate::error::DetectSentimentError::unhandled)?;
let error_code = match generic.code() {
Some(code) => code,
None => return Err(crate::error::DetectSentimentError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"InternalServerException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::InternalServerException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::internal_server_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_internal_server_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"InvalidRequestException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::InvalidRequestException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output = crate::error::invalid_request_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_invalid_request_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"TextSizeLimitExceededException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::TextSizeLimitExceededException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::error::text_size_limit_exceeded_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_text_size_limit_exceeded_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
"UnsupportedLanguageException" => crate::error::DetectSentimentError {
meta: generic,
kind: crate::error::DetectSentimentErrorKind::UnsupportedLanguageException({
#[allow(unused_mut)]
let mut tmp = {
#[allow(unused_mut)]
let mut output =
crate::error::unsupported_language_exception::Builder::default();
let _ = response;
output = crate::json_deser::deser_structure_crate_error_unsupported_language_exception_json_err(response.body().as_ref(), output).map_err(crate::error::DetectSentimentError::unhandled)?;
output.build()
};
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
},
_ => crate::error::DetectSentimentError::generic(generic),
})
}sourcepub fn meta(&self) -> &Error
pub fn meta(&self) -> &Error
Returns error metadata, which includes the error code, message, request ID, and potentially additional information.
sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns the request ID if it’s available.
sourcepub fn is_internal_server_exception(&self) -> bool
pub fn is_internal_server_exception(&self) -> bool
Returns true if the error kind is DetectSentimentErrorKind::InternalServerException.
sourcepub fn is_invalid_request_exception(&self) -> bool
pub fn is_invalid_request_exception(&self) -> bool
Returns true if the error kind is DetectSentimentErrorKind::InvalidRequestException.
sourcepub fn is_text_size_limit_exceeded_exception(&self) -> bool
pub fn is_text_size_limit_exceeded_exception(&self) -> bool
Returns true if the error kind is DetectSentimentErrorKind::TextSizeLimitExceededException.
sourcepub fn is_unsupported_language_exception(&self) -> bool
pub fn is_unsupported_language_exception(&self) -> bool
Returns true if the error kind is DetectSentimentErrorKind::UnsupportedLanguageException.