---
source: apollo-errors/crates/apollo-errors-derive/src/tests.rs
expression: pretty_print(output)
---
#[automatically_derived]
impl ::std::fmt::Display for SimpleStructError {
    fn fmt(
        &self,
        __apollo_formatter: &mut ::std::fmt::Formatter<'_>,
    ) -> ::std::fmt::Result {
        write!(__apollo_formatter, "Something went wrong")
    }
}
#[automatically_derived]
impl ::std::error::Error for SimpleStructError {
    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
        ::std::option::Option::None
    }
}
#[automatically_derived]
impl ::apollo_errors::Error for SimpleStructError {
    fn to_json(
        &self,
        config: ::apollo_errors::private::FormatConfig,
    ) -> ::std::result::Result<
        ::apollo_errors::private::serde_json::Value,
        ::apollo_errors::private::serde_json::Error,
    > {
        let __apollo_code = match config.code_case {
            ::apollo_errors::private::CodeCase::Default => "errors::struct_error",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => {
                "ERRORS_STRUCT_ERROR"
            }
            ::apollo_errors::private::CodeCase::CamelCase => "errorsStructError",
            ::apollo_errors::private::CodeCase::PascalCase => "ErrorsStructError",
            ::apollo_errors::private::CodeCase::KebabCase => "errors-struct-error",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        ::std::result::Result::Ok(
            ::apollo_errors::private::serde_json::json!(
                { "error" : __apollo_code, "message" : __apollo_message }
            ),
        )
    }
    fn to_html(
        &self,
        config: ::apollo_errors::private::FormatConfig,
    ) -> ::std::string::String {
        let __apollo_code = match config.code_case {
            ::apollo_errors::private::CodeCase::Default => "errors::struct_error",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => {
                "ERRORS_STRUCT_ERROR"
            }
            ::apollo_errors::private::CodeCase::CamelCase => "errorsStructError",
            ::apollo_errors::private::CodeCase::PascalCase => "ErrorsStructError",
            ::apollo_errors::private::CodeCase::KebabCase => "errors-struct-error",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        let __apollo_help_html = ::apollo_errors::private::diagnostic_help(self)
            .map(|h| {
                format!(
                    "<p class=\"error-help\">{}</p>",
                    ::apollo_errors::private::HtmlEscaped(h)
                )
            })
            .unwrap_or_default();
        let __apollo_extensions_html = ::std::string::String::new();
        format!(
            "<div class=\"error\">\n<h3 class=\"error-code\">{}</h3>\n<p class=\"error-message\">{}</p>\n{}{}\n</div>",
            ::apollo_errors::private::HtmlEscaped(__apollo_code),
            ::apollo_errors::private::HtmlEscaped(& __apollo_message),
            __apollo_help_html, __apollo_extensions_html
        )
    }
    fn to_graphql(
        &self,
        config: ::apollo_errors::private::FormatConfig,
    ) -> ::std::result::Result<
        ::apollo_errors::private::serde_json::Value,
        ::apollo_errors::private::serde_json::Error,
    > {
        let __apollo_code = match config.code_case {
            ::apollo_errors::private::CodeCase::Default => "errors::struct_error",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => {
                "ERRORS_STRUCT_ERROR"
            }
            ::apollo_errors::private::CodeCase::CamelCase => "errorsStructError",
            ::apollo_errors::private::CodeCase::PascalCase => "ErrorsStructError",
            ::apollo_errors::private::CodeCase::KebabCase => "errors-struct-error",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        ::std::result::Result::Ok(
            ::apollo_errors::private::serde_json::json!(
                { "message" : __apollo_message, "extensions" : { "code" : __apollo_code }
                }
            ),
        )
    }
    fn to_text(
        &self,
        config: ::apollo_errors::private::FormatConfig,
    ) -> ::std::string::String {
        let __apollo_code = match config.code_case {
            ::apollo_errors::private::CodeCase::Default => "errors::struct_error",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => {
                "ERRORS_STRUCT_ERROR"
            }
            ::apollo_errors::private::CodeCase::CamelCase => "errorsStructError",
            ::apollo_errors::private::CodeCase::PascalCase => "ErrorsStructError",
            ::apollo_errors::private::CodeCase::KebabCase => "errors-struct-error",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        format!("[{__apollo_code}] {__apollo_message}")
    }
    fn to_jsonrpc(
        &self,
        config: ::apollo_errors::private::FormatConfig,
    ) -> ::std::result::Result<
        ::apollo_errors::private::serde_json::Value,
        ::apollo_errors::private::serde_json::Error,
    > {
        let __apollo_diagnostic_code = match config.code_case {
            ::apollo_errors::private::CodeCase::Default => "errors::struct_error",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => {
                "ERRORS_STRUCT_ERROR"
            }
            ::apollo_errors::private::CodeCase::CamelCase => "errorsStructError",
            ::apollo_errors::private::CodeCase::PascalCase => "ErrorsStructError",
            ::apollo_errors::private::CodeCase::KebabCase => "errors-struct-error",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        ::std::result::Result::Ok(
            ::apollo_errors::private::serde_json::json!(
                { "code" : - 32000i32, "message" : __apollo_message, "data" : {
                "diagnostic_code" : __apollo_diagnostic_code } }
            ),
        )
    }
    fn http_status(&self) -> ::apollo_errors::http::StatusCode {
        ::http::StatusCode::INTERNAL_SERVER_ERROR
    }
    fn http_headers(
        &self,
    ) -> Vec<(::apollo_errors::http::HeaderName, ::apollo_errors::http::HeaderValue)> {
        Vec::new()
    }
}
static _APOLLO_ERROR_SIMPLESTRUCTERROR_FIELDS: &[::apollo_errors::private::FieldMetadata] = &[];
static _APOLLO_ERROR_SIMPLESTRUCTERROR_VARIANTS: &[::apollo_errors::private::VariantMetadata] = &[
    ::apollo_errors::private::VariantMetadata::Regular(::apollo_errors::private::RegularVariantMetadata {
        name: "SimpleStructError",
        message: "Something went wrong",
        code: "errors::struct_error",
        code_screaming_snake: "ERRORS_STRUCT_ERROR",
        code_camel: "errorsStructError",
        code_pascal: "ErrorsStructError",
        code_kebab: "errors-struct-error",
        http_status: 500u16,
        jsonrpc_code: -32000i32,
        help: None,
        url: None,
        severity: None,
        fields: _APOLLO_ERROR_SIMPLESTRUCTERROR_FIELDS,
    }),
];
static _APOLLO_ERROR_SIMPLESTRUCTERROR_METADATA: ::apollo_errors::private::ErrorMetadata = ::apollo_errors::private::ErrorMetadata {
    type_name: "SimpleStructError",
    variants: _APOLLO_ERROR_SIMPLESTRUCTERROR_VARIANTS,
};
fn _apollo_error_simplestructerror_render_json(
    error: &(dyn std::error::Error + 'static),
    config: ::apollo_errors::private::FormatConfig,
) -> Option<
    ::std::result::Result<
        ::apollo_errors::private::serde_json::Value,
        ::apollo_errors::private::serde_json::Error,
    >,
> {
    if let Some(concrete) = error.downcast_ref::<SimpleStructError>() {
        return Some(::apollo_errors::Error::to_json(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_json(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_json(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<SimpleStructError>>>()
    {
        return Some(::apollo_errors::Error::to_json(box_arc.as_ref().as_ref(), config));
    }
    None
}
fn _apollo_error_simplestructerror_render_html(
    error: &(dyn std::error::Error + 'static),
    config: ::apollo_errors::private::FormatConfig,
) -> Option<String> {
    if let Some(concrete) = error.downcast_ref::<SimpleStructError>() {
        return Some(::apollo_errors::Error::to_html(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_html(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_html(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<SimpleStructError>>>()
    {
        return Some(::apollo_errors::Error::to_html(box_arc.as_ref().as_ref(), config));
    }
    None
}
fn _apollo_error_simplestructerror_render_graphql(
    error: &(dyn std::error::Error + 'static),
    config: ::apollo_errors::private::FormatConfig,
) -> Option<
    ::std::result::Result<
        ::apollo_errors::private::serde_json::Value,
        ::apollo_errors::private::serde_json::Error,
    >,
> {
    if let Some(concrete) = error.downcast_ref::<SimpleStructError>() {
        return Some(::apollo_errors::Error::to_graphql(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_graphql(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_graphql(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<SimpleStructError>>>()
    {
        return Some(
            ::apollo_errors::Error::to_graphql(box_arc.as_ref().as_ref(), config),
        );
    }
    None
}
fn _apollo_error_simplestructerror_render_text(
    error: &(dyn std::error::Error + 'static),
    config: ::apollo_errors::private::FormatConfig,
) -> Option<String> {
    if let Some(concrete) = error.downcast_ref::<SimpleStructError>() {
        return Some(::apollo_errors::Error::to_text(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_text(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_text(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<SimpleStructError>>>()
    {
        return Some(::apollo_errors::Error::to_text(box_arc.as_ref().as_ref(), config));
    }
    None
}
fn _apollo_error_simplestructerror_http_status(
    error: &(dyn std::error::Error + 'static),
) -> Option<::apollo_errors::http::StatusCode> {
    if let Some(concrete) = error.downcast_ref::<SimpleStructError>() {
        return Some(::apollo_errors::Error::http_status(concrete));
    }
    if let Some(boxed) = error.downcast_ref::<Box<SimpleStructError>>() {
        return Some(::apollo_errors::Error::http_status(boxed.as_ref()));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<SimpleStructError>>() {
        return Some(::apollo_errors::Error::http_status(arc.as_ref()));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<SimpleStructError>>>()
    {
        return Some(::apollo_errors::Error::http_status(box_arc.as_ref().as_ref()));
    }
    None
}
fn _apollo_error_simplestructerror_render_jsonrpc(
    error: &(dyn std::error::Error + 'static),
    config: ::apollo_errors::private::FormatConfig,
) -> Option<
    ::std::result::Result<
        ::apollo_errors::private::serde_json::Value,
        ::apollo_errors::private::serde_json::Error,
    >,
> {
    if let Some(concrete) = error.downcast_ref::<SimpleStructError>() {
        return Some(::apollo_errors::Error::to_jsonrpc(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_jsonrpc(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<SimpleStructError>>() {
        return Some(::apollo_errors::Error::to_jsonrpc(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<SimpleStructError>>>()
    {
        return Some(
            ::apollo_errors::Error::to_jsonrpc(box_arc.as_ref().as_ref(), config),
        );
    }
    None
}
fn _apollo_error_simplestructerror_http_headers(
    error: &(dyn std::error::Error + 'static),
) -> Option<
    Vec<(::apollo_errors::http::HeaderName, ::apollo_errors::http::HeaderValue)>,
> {
    if let Some(concrete) = error.downcast_ref::<SimpleStructError>() {
        return Some(::apollo_errors::Error::http_headers(concrete));
    }
    if let Some(boxed) = error.downcast_ref::<Box<SimpleStructError>>() {
        return Some(::apollo_errors::Error::http_headers(boxed.as_ref()));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<SimpleStructError>>() {
        return Some(::apollo_errors::Error::http_headers(arc.as_ref()));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<SimpleStructError>>>()
    {
        return Some(::apollo_errors::Error::http_headers(box_arc.as_ref().as_ref()));
    }
    None
}
#[::apollo_errors::private::linkme::distributed_slice(
    ::apollo_errors::private::ERROR_REGISTRY
)]
#[linkme(crate = ::apollo_errors::private::linkme)]
#[doc(hidden)]
static _APOLLO_ERROR_SIMPLESTRUCTERROR_REGISTRY_ENTRY: ::apollo_errors::private::ErrorRegistryEntry = ::apollo_errors::private::ErrorRegistryEntry {
    type_id: std::any::TypeId::of::<SimpleStructError>(),
    type_name: "SimpleStructError",
    metadata: &_APOLLO_ERROR_SIMPLESTRUCTERROR_METADATA,
    render_json: _apollo_error_simplestructerror_render_json,
    render_html: _apollo_error_simplestructerror_render_html,
    render_graphql: _apollo_error_simplestructerror_render_graphql,
    render_text: _apollo_error_simplestructerror_render_text,
    http_status: _apollo_error_simplestructerror_http_status,
    render_jsonrpc: _apollo_error_simplestructerror_render_jsonrpc,
    http_headers: _apollo_error_simplestructerror_http_headers,
};
