pub fn try_from_error(
        err: Box<dyn Error + Send + Sync + 'static>,
    ) -> Result<Status, Box<dyn Error + Send + Sync + 'static>> {
        let err = match err.downcast::<Status>() {
            Ok(status) => {
                return Ok(*status);
            }
            Err(err) => err,
        };

        #[cfg(feature = "server")]
        let err = match err.downcast::<h2::Error>() {
            Ok(h2) => {
                return Ok(Status::from_h2_error(h2));
            }
            Err(err) => err,
        };

        // If the load shed middleware is enabled, respond to
        // service overloaded with an appropriate grpc status.
        #[cfg(feature = "server")]
        let err = match err.downcast::<tower::load_shed::error::Overloaded>() {
            Ok(_) => {
                return Ok(Status::resource_exhausted(
                    "Too many active requests for the connection",
                ));
            }
            Err(err) => err,
        };

        if let Some(mut status) = find_status_in_source_chain(&*err) {
            status.0.source = Some(err.into());
            return Ok(status);
        }

        Err(err)
    }
Create a `Status` from various types of `Error`.

Returns the error if a status could not be created.

# Downcast stability
This function does not provide any stability guarantees around how it will downcast errors into
status codes.
tonic/src/status.rs