aws: rely on WaitError Display implementation

The Display implementation of WaitError already displays the underlying
SDK error and the metadata, so can just use that.

Will also be used to provide more context in the next patch.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1638>
This commit is contained in:
Guillaume Desmottes 2024-06-26 10:41:55 +02:00
parent 0bd98e2c34
commit 3b7b2cd37b
3 changed files with 21 additions and 24 deletions

View file

@ -14,7 +14,6 @@ use gst_base::subclass::prelude::*;
use aws_sdk_s3::{
config::{self, retry::RetryConfig, Credentials, Region},
error::ProvideErrorMetadata,
operation::{
abort_multipart_upload::builders::AbortMultipartUploadFluentBuilder,
complete_multipart_upload::builders::CompleteMultipartUploadFluentBuilder,
@ -269,12 +268,12 @@ impl S3Sink {
let upload_part_req_future = upload_part_req.send();
let output =
s3utils::wait(&self.canceller, upload_part_req_future).map_err(|err| match err {
WaitError::FutureError(err) => {
s3utils::wait(&self.canceller, upload_part_req_future).map_err(|err| match &err {
WaitError::FutureError(_) => {
self.flush_multipart_upload(state);
Some(gst::error_msg!(
gst::ResourceError::OpenWrite,
["Failed to upload part: {err}: {}", err.meta()]
["Failed to upload part: {err}"]
))
}
WaitError::Cancelled => None,
@ -418,11 +417,11 @@ impl S3Sink {
s3utils::wait(&self.abort_multipart_canceller, abort_req_future)
.map(|_| ())
.map_err(|err| match err {
WaitError::FutureError(err) => {
.map_err(|err| match &err {
WaitError::FutureError(_) => {
gst::error_msg!(
gst::ResourceError::Write,
["Failed to abort multipart upload: {err}: {}", err.meta()]
["Failed to abort multipart upload: {err}"]
)
}
WaitError::Cancelled => {
@ -443,10 +442,10 @@ impl S3Sink {
s3utils::wait(&self.canceller, complete_req_future)
.map(|_| ())
.map_err(|err| match err {
WaitError::FutureError(err) => gst::error_msg!(
.map_err(|err| match &err {
WaitError::FutureError(_) => gst::error_msg!(
gst::ResourceError::Write,
["Failed to complete multipart upload: {err}: {}", err.meta()]
["Failed to complete multipart upload: {err}"]
),
WaitError::Cancelled => {
gst::error_msg!(
@ -554,10 +553,10 @@ impl S3Sink {
let create_multipart_req_future = create_multipart_req.send();
let response = s3utils::wait(&self.canceller, create_multipart_req_future).map_err(
|err| match err {
WaitError::FutureError(err) => gst::error_msg!(
|err| match &err {
WaitError::FutureError(_) => gst::error_msg!(
gst::ResourceError::OpenWrite,
["Failed to create multipart upload: {err}: {}", err.meta()]
["Failed to create multipart upload: {err}"]
),
WaitError::Cancelled => {
gst::error_msg!(

View file

@ -15,7 +15,6 @@ use gst_base::subclass::prelude::*;
use aws_sdk_s3::{
config::{self, retry::RetryConfig, Credentials, Region},
error::ProvideErrorMetadata,
operation::put_object::builders::PutObjectFluentBuilder,
primitives::ByteStream,
Client,
@ -208,10 +207,10 @@ impl S3PutObjectSink {
let put_object_req_future = put_object_req.send();
let _output =
s3utils::wait(&self.canceller, put_object_req_future).map_err(|err| match err {
WaitError::FutureError(err) => Some(gst::error_msg!(
s3utils::wait(&self.canceller, put_object_req_future).map_err(|err| match &err {
WaitError::FutureError(_) => Some(gst::error_msg!(
gst::ResourceError::OpenWrite,
["Failed to upload object: {err}: {}", err.meta()]
["Failed to upload object: {err}"]
)),
WaitError::Cancelled => None,
})?;

View file

@ -13,7 +13,6 @@ use std::time::Duration;
use aws_sdk_s3::{
config::{self, retry::RetryConfig, Credentials},
error::ProvideErrorMetadata,
Client,
};
@ -177,10 +176,10 @@ impl S3Src {
let head_object_future = head_object.send();
let output =
s3utils::wait(&self.canceller, head_object_future).map_err(|err| match err {
WaitError::FutureError(err) => gst::error_msg!(
s3utils::wait(&self.canceller, head_object_future).map_err(|err| match &err {
WaitError::FutureError(_) => gst::error_msg!(
gst::ResourceError::NotFound,
["Failed to get HEAD object: {err}: {}", err.meta()]
["Failed to get HEAD object: {err}"]
),
WaitError::Cancelled => {
gst::error_msg!(
@ -236,10 +235,10 @@ impl S3Src {
let get_object_future = get_object.send();
let mut output =
s3utils::wait(&self.canceller, get_object_future).map_err(|err| match err {
WaitError::FutureError(err) => Some(gst::error_msg!(
s3utils::wait(&self.canceller, get_object_future).map_err(|err| match &err {
WaitError::FutureError(_) => Some(gst::error_msg!(
gst::ResourceError::Read,
["Could not read: {err}: {}", err.meta()]
["Could not read: {err}"]
)),
WaitError::Cancelled => None,
})?;