Error Handling with player
Trying to identify resource errors in gst-player(-rs) is currently plain string-matching as gst-player seems to wrap all errors into PlayerError::Failure (its only type). For example when a resource errors out, like a 403-Forbidden on a http resource, gst-player throws a generic player-error and no ResourceError::NotAuthorized is thrown. Also one has to rely on .to_string() as the message can't be accessed directly, which feels hacky and subject to change (and thus fail) at any time.
For example using the ResoureError won't detect it:
if let Some(err) = e.kind::<ResourceError>() {
match err {
ResourceError::NotAuthorized | ResourceError::NotFound => {
info!(
"Unable to read resource:{:?} for instance {}",
err, event.id
);
retry = true;
}
v => warn!("Resource error {:?} for instance {}", v, event.id),
}
}
So I end up with the following for detecting resource errors:
if e.is::<PlayerError>() {
if err_str.contains("Forbidden (403)") {
debug!("Arcane magic detected URL Forbidden error, retrying..");
retry = true;
}
}