---
source: apollo-errors/crates/apollo-errors-derive/src/tests.rs
expression: pretty_print(output)
---
#[automatically_derived]
impl ::std::fmt::Display for NotFoundError {
    fn fmt(
        &self,
        __apollo_formatter: &mut ::std::fmt::Formatter<'_>,
    ) -> ::std::fmt::Result {
        let resource = &self.resource;
        write!(__apollo_formatter, "Not found")
    }
}
#[automatically_derived]
impl ::std::error::Error for NotFoundError {
    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
        ::std::option::Option::None
    }
}
#[automatically_derived]
impl ::apollo_errors::Error for NotFoundError {
    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 => "http::not_found",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => "HTTP_NOT_FOUND",
            ::apollo_errors::private::CodeCase::CamelCase => "httpNotFound",
            ::apollo_errors::private::CodeCase::PascalCase => "HttpNotFound",
            ::apollo_errors::private::CodeCase::KebabCase => "http-not-found",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        let mut __apollo_obj = ::apollo_errors::private::serde_json::json!(
            { "error" : __apollo_code, "message" : __apollo_message }
        );
        if let ::apollo_errors::private::serde_json::Value::Object(
            ref mut __apollo_map,
        ) = __apollo_obj {
            if let ::std::option::Option::Some((__apollo_key, __apollo_value)) = ::std::option::Option::Some((
                match config.field_case {
                    ::apollo_errors::private::FieldCase::SnakeCase => "resource",
                    ::apollo_errors::private::FieldCase::CamelCase => "resource",
                    ::apollo_errors::private::FieldCase::PascalCase => "Resource",
                    ::apollo_errors::private::FieldCase::ScreamingSnakeCase => "RESOURCE",
                    ::apollo_errors::private::FieldCase::KebabCase => "resource",
                },
                ::apollo_errors::private::serde_json::to_value(&self.resource)
                    .unwrap_or(::apollo_errors::private::serde_json::Value::Null),
            )) {
                __apollo_map.insert(__apollo_key.to_string(), __apollo_value);
            }
        }
        ::std::result::Result::Ok(__apollo_obj)
    }
    fn to_html(
        &self,
        config: ::apollo_errors::private::FormatConfig,
    ) -> ::std::string::String {
        let __apollo_code = match config.code_case {
            ::apollo_errors::private::CodeCase::Default => "http::not_found",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => "HTTP_NOT_FOUND",
            ::apollo_errors::private::CodeCase::CamelCase => "httpNotFound",
            ::apollo_errors::private::CodeCase::PascalCase => "HttpNotFound",
            ::apollo_errors::private::CodeCase::KebabCase => "http-not-found",
        };
        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 = {
            let mut __apollo_fields: Vec<::std::string::String> = Vec::new();
            if let ::std::option::Option::Some(__apollo_field_html) = ::std::option::Option::Some(
                format!(
                    "<div class=\"error-field\"><span class=\"field-name\">{}:</span> <span class=\"field-value\">{}</span></div>",
                    match config.field_case {
                    ::apollo_errors::private::FieldCase::SnakeCase => "resource",
                    ::apollo_errors::private::FieldCase::CamelCase => "resource",
                    ::apollo_errors::private::FieldCase::PascalCase => "Resource",
                    ::apollo_errors::private::FieldCase::ScreamingSnakeCase =>
                    "RESOURCE", ::apollo_errors::private::FieldCase::KebabCase =>
                    "resource", }, ::apollo_errors::private::HtmlEscaped(& self.resource)
                ),
            ) {
                __apollo_fields.push(__apollo_field_html);
            }
            if __apollo_fields.is_empty() {
                ::std::string::String::new()
            } else {
                format!(
                    "\n<div class=\"error-extensions\">\n{}\n</div>", __apollo_fields
                    .join("\n")
                )
            }
        };
        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 => "http::not_found",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => "HTTP_NOT_FOUND",
            ::apollo_errors::private::CodeCase::CamelCase => "httpNotFound",
            ::apollo_errors::private::CodeCase::PascalCase => "HttpNotFound",
            ::apollo_errors::private::CodeCase::KebabCase => "http-not-found",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        let mut __apollo_extensions = ::apollo_errors::private::serde_json::json!(
            { "code" : __apollo_code }
        );
        if let ::apollo_errors::private::serde_json::Value::Object(
            ref mut __apollo_map,
        ) = __apollo_extensions {
            if let ::std::option::Option::Some((__apollo_key, __apollo_value)) = ::std::option::Option::Some((
                match config.field_case {
                    ::apollo_errors::private::FieldCase::SnakeCase => "resource",
                    ::apollo_errors::private::FieldCase::CamelCase => "resource",
                    ::apollo_errors::private::FieldCase::PascalCase => "Resource",
                    ::apollo_errors::private::FieldCase::ScreamingSnakeCase => "RESOURCE",
                    ::apollo_errors::private::FieldCase::KebabCase => "resource",
                },
                ::apollo_errors::private::serde_json::to_value(&self.resource)
                    .unwrap_or(::apollo_errors::private::serde_json::Value::Null),
            )) {
                __apollo_map.insert(__apollo_key.to_string(), __apollo_value);
            }
        }
        ::std::result::Result::Ok(
            ::apollo_errors::private::serde_json::json!(
                { "message" : __apollo_message, "extensions" : __apollo_extensions }
            ),
        )
    }
    fn to_text(
        &self,
        config: ::apollo_errors::private::FormatConfig,
    ) -> ::std::string::String {
        let __apollo_code = match config.code_case {
            ::apollo_errors::private::CodeCase::Default => "http::not_found",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => "HTTP_NOT_FOUND",
            ::apollo_errors::private::CodeCase::CamelCase => "httpNotFound",
            ::apollo_errors::private::CodeCase::PascalCase => "HttpNotFound",
            ::apollo_errors::private::CodeCase::KebabCase => "http-not-found",
        };
        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 => "http::not_found",
            ::apollo_errors::private::CodeCase::ScreamingSnakeCase => "HTTP_NOT_FOUND",
            ::apollo_errors::private::CodeCase::CamelCase => "httpNotFound",
            ::apollo_errors::private::CodeCase::PascalCase => "HttpNotFound",
            ::apollo_errors::private::CodeCase::KebabCase => "http-not-found",
        };
        let __apollo_message = ::std::string::ToString::to_string(self);
        let mut __apollo_data = ::apollo_errors::private::serde_json::json!(
            { "diagnostic_code" : __apollo_diagnostic_code }
        );
        if let ::apollo_errors::private::serde_json::Value::Object(
            ref mut __apollo_map,
        ) = __apollo_data {
            if let ::std::option::Option::Some((__apollo_key, __apollo_value)) = ::std::option::Option::Some((
                match config.field_case {
                    ::apollo_errors::private::FieldCase::SnakeCase => "resource",
                    ::apollo_errors::private::FieldCase::CamelCase => "resource",
                    ::apollo_errors::private::FieldCase::PascalCase => "Resource",
                    ::apollo_errors::private::FieldCase::ScreamingSnakeCase => "RESOURCE",
                    ::apollo_errors::private::FieldCase::KebabCase => "resource",
                },
                ::apollo_errors::private::serde_json::to_value(&self.resource)
                    .unwrap_or(::apollo_errors::private::serde_json::Value::Null),
            )) {
                __apollo_map.insert(__apollo_key.to_string(), __apollo_value);
            }
        }
        ::std::result::Result::Ok(
            ::apollo_errors::private::serde_json::json!(
                { "code" : - 32000i32, "message" : __apollo_message, "data" :
                __apollo_data }
            ),
        )
    }
    fn http_status(&self) -> ::apollo_errors::http::StatusCode {
        ::apollo_errors::private::http_status_from_u16(404u16)
    }
    fn http_headers(
        &self,
    ) -> Vec<(::apollo_errors::http::HeaderName, ::apollo_errors::http::HeaderValue)> {
        Vec::new()
    }
}
static _APOLLO_ERROR_NOTFOUNDERROR_FIELDS: &[::apollo_errors::private::FieldMetadata] = &[
    ::apollo_errors::private::FieldMetadata {
        rust_name: "resource",
        output_name: "resource",
        snake_case: "resource",
        camel_case: "resource",
        pascal_case: "Resource",
        screaming_snake_case: "RESOURCE",
        kebab_case: "resource",
        ty: "String",
        is_extension: true,
        http_header: None,
    },
];
static _APOLLO_ERROR_NOTFOUNDERROR_VARIANTS: &[::apollo_errors::private::VariantMetadata] = &[
    ::apollo_errors::private::VariantMetadata::Regular(::apollo_errors::private::RegularVariantMetadata {
        name: "NotFoundError",
        message: "Not found",
        code: "http::not_found",
        code_screaming_snake: "HTTP_NOT_FOUND",
        code_camel: "httpNotFound",
        code_pascal: "HttpNotFound",
        code_kebab: "http-not-found",
        http_status: 404u16,
        jsonrpc_code: -32000i32,
        help: None,
        url: None,
        severity: None,
        fields: _APOLLO_ERROR_NOTFOUNDERROR_FIELDS,
    }),
];
static _APOLLO_ERROR_NOTFOUNDERROR_METADATA: ::apollo_errors::private::ErrorMetadata = ::apollo_errors::private::ErrorMetadata {
    type_name: "NotFoundError",
    variants: _APOLLO_ERROR_NOTFOUNDERROR_VARIANTS,
};
fn _apollo_error_notfounderror_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::<NotFoundError>() {
        return Some(::apollo_errors::Error::to_json(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_json(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_json(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<NotFoundError>>>() {
        return Some(::apollo_errors::Error::to_json(box_arc.as_ref().as_ref(), config));
    }
    None
}
fn _apollo_error_notfounderror_render_html(
    error: &(dyn std::error::Error + 'static),
    config: ::apollo_errors::private::FormatConfig,
) -> Option<String> {
    if let Some(concrete) = error.downcast_ref::<NotFoundError>() {
        return Some(::apollo_errors::Error::to_html(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_html(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_html(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<NotFoundError>>>() {
        return Some(::apollo_errors::Error::to_html(box_arc.as_ref().as_ref(), config));
    }
    None
}
fn _apollo_error_notfounderror_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::<NotFoundError>() {
        return Some(::apollo_errors::Error::to_graphql(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_graphql(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_graphql(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<NotFoundError>>>() {
        return Some(
            ::apollo_errors::Error::to_graphql(box_arc.as_ref().as_ref(), config),
        );
    }
    None
}
fn _apollo_error_notfounderror_render_text(
    error: &(dyn std::error::Error + 'static),
    config: ::apollo_errors::private::FormatConfig,
) -> Option<String> {
    if let Some(concrete) = error.downcast_ref::<NotFoundError>() {
        return Some(::apollo_errors::Error::to_text(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_text(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_text(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<NotFoundError>>>() {
        return Some(::apollo_errors::Error::to_text(box_arc.as_ref().as_ref(), config));
    }
    None
}
fn _apollo_error_notfounderror_http_status(
    error: &(dyn std::error::Error + 'static),
) -> Option<::apollo_errors::http::StatusCode> {
    if let Some(concrete) = error.downcast_ref::<NotFoundError>() {
        return Some(::apollo_errors::Error::http_status(concrete));
    }
    if let Some(boxed) = error.downcast_ref::<Box<NotFoundError>>() {
        return Some(::apollo_errors::Error::http_status(boxed.as_ref()));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<NotFoundError>>() {
        return Some(::apollo_errors::Error::http_status(arc.as_ref()));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<NotFoundError>>>() {
        return Some(::apollo_errors::Error::http_status(box_arc.as_ref().as_ref()));
    }
    None
}
fn _apollo_error_notfounderror_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::<NotFoundError>() {
        return Some(::apollo_errors::Error::to_jsonrpc(concrete, config));
    }
    if let Some(boxed) = error.downcast_ref::<Box<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_jsonrpc(boxed.as_ref(), config));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<NotFoundError>>() {
        return Some(::apollo_errors::Error::to_jsonrpc(arc.as_ref(), config));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<NotFoundError>>>() {
        return Some(
            ::apollo_errors::Error::to_jsonrpc(box_arc.as_ref().as_ref(), config),
        );
    }
    None
}
fn _apollo_error_notfounderror_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::<NotFoundError>() {
        return Some(::apollo_errors::Error::http_headers(concrete));
    }
    if let Some(boxed) = error.downcast_ref::<Box<NotFoundError>>() {
        return Some(::apollo_errors::Error::http_headers(boxed.as_ref()));
    }
    if let Some(arc) = error.downcast_ref::<std::sync::Arc<NotFoundError>>() {
        return Some(::apollo_errors::Error::http_headers(arc.as_ref()));
    }
    if let Some(box_arc) = error.downcast_ref::<Box<std::sync::Arc<NotFoundError>>>() {
        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_NOTFOUNDERROR_REGISTRY_ENTRY: ::apollo_errors::private::ErrorRegistryEntry = ::apollo_errors::private::ErrorRegistryEntry {
    type_id: std::any::TypeId::of::<NotFoundError>(),
    type_name: "NotFoundError",
    metadata: &_APOLLO_ERROR_NOTFOUNDERROR_METADATA,
    render_json: _apollo_error_notfounderror_render_json,
    render_html: _apollo_error_notfounderror_render_html,
    render_graphql: _apollo_error_notfounderror_render_graphql,
    render_text: _apollo_error_notfounderror_render_text,
    http_status: _apollo_error_notfounderror_http_status,
    render_jsonrpc: _apollo_error_notfounderror_render_jsonrpc,
    http_headers: _apollo_error_notfounderror_http_headers,
};
