// @generated by Thrift for thrift/compiler/test/fixtures/exceptions/src/module.thrift // This file is probably not the place you want to edit! //! Thrift error definitions for `module`. /// Error definitions for `Raiser`. pub mod raiser { pub trait AsBanal { fn as_banal(&self) -> Option<&crate::types::Banal>; } impl AsBanal for ::anyhow::Error { fn as_banal(&self) -> Option<&crate::types::Banal> { for cause in self.chain() { if let Some(DoRaiseError::b(e)) = cause.downcast_ref::() { return Some(e); } if let Some(Get500Error::b(e)) = cause.downcast_ref::() { return Some(e); } } None } } pub trait AsFiery { fn as_fiery(&self) -> Option<&crate::types::Fiery>; } impl AsFiery for ::anyhow::Error { fn as_fiery(&self) -> Option<&crate::types::Fiery> { for cause in self.chain() { if let Some(DoRaiseError::f(e)) = cause.downcast_ref::() { return Some(e); } if let Some(Get500Error::f(e)) = cause.downcast_ref::() { return Some(e); } } None } } pub trait AsSerious { fn as_serious(&self) -> Option<&crate::types::Serious>; } impl AsSerious for ::anyhow::Error { fn as_serious(&self) -> Option<&crate::types::Serious> { for cause in self.chain() { if let Some(DoRaiseError::s(e)) = cause.downcast_ref::() { return Some(e); } if let Some(Get500Error::s(e)) = cause.downcast_ref::() { return Some(e); } } None } } pub type DoBlandError = ::fbthrift::NonthrowingFunctionError; impl ::std::convert::From for ::std::result::Result<(), DoBlandError> { fn from(e: crate::services::raiser::DoBlandExn) -> Self { match e { crate::services::raiser::DoBlandExn::Success(res) => { ::std::result::Result::Ok(res) } crate::services::raiser::DoBlandExn::ApplicationException(aexn) => ::std::result::Result::Err(DoBlandError::ApplicationException(aexn)), } } } /// Errors for doRaise (client side). #[derive(Debug)] pub enum DoRaiseError { b(crate::types::Banal), f(crate::types::Fiery), s(crate::types::Serious), ApplicationException(::fbthrift::ApplicationException), ThriftError(::anyhow::Error), } /// Human-readable string representation of the Thrift client error. /// /// By default, this will not print the full cause chain. If you would like to print the underlying error /// cause, either use `format!("{:?}", anyhow::Error::from(client_err))` or print this using the /// alternate formatter `{:#}` instead of just `{}`. impl ::std::fmt::Display for DoRaiseError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::result::Result<(), ::std::fmt::Error> { match self { Self::b(inner) => { if f.alternate() { write!(f, "Raiser::doRaise failed with variant `b`: {:#}", inner)?; } else { write!(f, "Raiser::doRaise failed with b(Banal)")?; } } Self::f(inner) => { if f.alternate() { write!(f, "Raiser::doRaise failed with variant `f`: {:#}", inner)?; } else { write!(f, "Raiser::doRaise failed with f(Fiery)")?; } } Self::s(inner) => { if f.alternate() { write!(f, "Raiser::doRaise failed with variant `s`: {:#}", inner)?; } else { write!(f, "Raiser::doRaise failed with s(Serious)")?; } } Self::ApplicationException(inner) => { write!(f, "Raiser::doRaise failed with ApplicationException")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } Self::ThriftError(inner) => { write!(f, "Raiser::doRaise failed with ThriftError")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } } Ok(()) } } impl ::std::error::Error for DoRaiseError { fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { match self { Self::b(ref inner) => { Some(inner) } Self::f(ref inner) => { Some(inner) } Self::s(ref inner) => { Some(inner) } Self::ApplicationException(ref inner) => { Some(inner) } Self::ThriftError(ref inner) => { Some(inner.as_ref()) } } } } impl ::std::convert::From for DoRaiseError { fn from(e: crate::types::Banal) -> Self { Self::b(e) } } impl AsBanal for DoRaiseError { fn as_banal(&self) -> Option<&crate::types::Banal> { match self { Self::b(inner) => Some(inner), _ => None, } } } impl ::std::convert::From for DoRaiseError { fn from(e: crate::types::Fiery) -> Self { Self::f(e) } } impl AsFiery for DoRaiseError { fn as_fiery(&self) -> Option<&crate::types::Fiery> { match self { Self::f(inner) => Some(inner), _ => None, } } } impl ::std::convert::From for DoRaiseError { fn from(e: crate::types::Serious) -> Self { Self::s(e) } } impl AsSerious for DoRaiseError { fn as_serious(&self) -> Option<&crate::types::Serious> { match self { Self::s(inner) => Some(inner), _ => None, } } } impl ::std::convert::From<::anyhow::Error> for DoRaiseError { fn from(err: ::anyhow::Error) -> Self { Self::ThriftError(err) } } impl ::std::convert::From<::fbthrift::ApplicationException> for DoRaiseError { fn from(ae: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(ae) } } impl ::std::convert::From for ::std::result::Result<(), DoRaiseError> { fn from(e: crate::services::raiser::DoRaiseExn) -> Self { match e { crate::services::raiser::DoRaiseExn::Success(res) => { ::std::result::Result::Ok(res) } crate::services::raiser::DoRaiseExn::ApplicationException(aexn) => ::std::result::Result::Err(DoRaiseError::ApplicationException(aexn)), crate::services::raiser::DoRaiseExn::b(exn) => ::std::result::Result::Err(DoRaiseError::b(exn)), crate::services::raiser::DoRaiseExn::f(exn) => ::std::result::Result::Err(DoRaiseError::f(exn)), crate::services::raiser::DoRaiseExn::s(exn) => ::std::result::Result::Err(DoRaiseError::s(exn)), } } } pub type Get200Error = ::fbthrift::NonthrowingFunctionError; impl ::std::convert::From for ::std::result::Result<::std::string::String, Get200Error> { fn from(e: crate::services::raiser::Get200Exn) -> Self { match e { crate::services::raiser::Get200Exn::Success(res) => { ::std::result::Result::Ok(res) } crate::services::raiser::Get200Exn::ApplicationException(aexn) => ::std::result::Result::Err(Get200Error::ApplicationException(aexn)), } } } /// Errors for get500 (client side). #[derive(Debug)] pub enum Get500Error { f(crate::types::Fiery), b(crate::types::Banal), s(crate::types::Serious), ApplicationException(::fbthrift::ApplicationException), ThriftError(::anyhow::Error), } /// Human-readable string representation of the Thrift client error. /// /// By default, this will not print the full cause chain. If you would like to print the underlying error /// cause, either use `format!("{:?}", anyhow::Error::from(client_err))` or print this using the /// alternate formatter `{:#}` instead of just `{}`. impl ::std::fmt::Display for Get500Error { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::result::Result<(), ::std::fmt::Error> { match self { Self::f(inner) => { if f.alternate() { write!(f, "Raiser::get500 failed with variant `f`: {:#}", inner)?; } else { write!(f, "Raiser::get500 failed with f(Fiery)")?; } } Self::b(inner) => { if f.alternate() { write!(f, "Raiser::get500 failed with variant `b`: {:#}", inner)?; } else { write!(f, "Raiser::get500 failed with b(Banal)")?; } } Self::s(inner) => { if f.alternate() { write!(f, "Raiser::get500 failed with variant `s`: {:#}", inner)?; } else { write!(f, "Raiser::get500 failed with s(Serious)")?; } } Self::ApplicationException(inner) => { write!(f, "Raiser::get500 failed with ApplicationException")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } Self::ThriftError(inner) => { write!(f, "Raiser::get500 failed with ThriftError")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } } Ok(()) } } impl ::std::error::Error for Get500Error { fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { match self { Self::f(ref inner) => { Some(inner) } Self::b(ref inner) => { Some(inner) } Self::s(ref inner) => { Some(inner) } Self::ApplicationException(ref inner) => { Some(inner) } Self::ThriftError(ref inner) => { Some(inner.as_ref()) } } } } impl ::std::convert::From for Get500Error { fn from(e: crate::types::Fiery) -> Self { Self::f(e) } } impl AsFiery for Get500Error { fn as_fiery(&self) -> Option<&crate::types::Fiery> { match self { Self::f(inner) => Some(inner), _ => None, } } } impl ::std::convert::From for Get500Error { fn from(e: crate::types::Banal) -> Self { Self::b(e) } } impl AsBanal for Get500Error { fn as_banal(&self) -> Option<&crate::types::Banal> { match self { Self::b(inner) => Some(inner), _ => None, } } } impl ::std::convert::From for Get500Error { fn from(e: crate::types::Serious) -> Self { Self::s(e) } } impl AsSerious for Get500Error { fn as_serious(&self) -> Option<&crate::types::Serious> { match self { Self::s(inner) => Some(inner), _ => None, } } } impl ::std::convert::From<::anyhow::Error> for Get500Error { fn from(err: ::anyhow::Error) -> Self { Self::ThriftError(err) } } impl ::std::convert::From<::fbthrift::ApplicationException> for Get500Error { fn from(ae: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(ae) } } impl ::std::convert::From for ::std::result::Result<::std::string::String, Get500Error> { fn from(e: crate::services::raiser::Get500Exn) -> Self { match e { crate::services::raiser::Get500Exn::Success(res) => { ::std::result::Result::Ok(res) } crate::services::raiser::Get500Exn::ApplicationException(aexn) => ::std::result::Result::Err(Get500Error::ApplicationException(aexn)), crate::services::raiser::Get500Exn::f(exn) => ::std::result::Result::Err(Get500Error::f(exn)), crate::services::raiser::Get500Exn::b(exn) => ::std::result::Result::Err(Get500Error::b(exn)), crate::services::raiser::Get500Exn::s(exn) => ::std::result::Result::Err(Get500Error::s(exn)), } } } }