import { faCircleExclamation } from "@fortawesome/free-solid-svg-icons";
import { FestaIcon } from "../renderers/fontawesome";
import { default as classNames } from "classnames"
import style from "./renderers.module.css"
import { memo } from "react";
import { AxiosError } from "axios";
export type ErrorTraceProps = {
error: Error,
inline: boolean,
}
export const ErrorTrace = memo((props: ErrorTraceProps) => {
if (props.error instanceof AxiosError) {
if (props.error.response) {
if (props.error.response.data) {
const json = JSON.stringify(props.error.response.data, undefined, props.inline ? undefined : 4).replaceAll("\\n", "\n")
return (
API {props.error.response.status}
:
{json}
)
}
return (
HTTP {props.error.response.status}
:
{props.error.message}
)
}
return (
{props.error.code}
:
{props.error.message}
)
}
return (
{props.error.name}
:
{props.error.message}
)
})
export type ErrorInlineProps = {
error: Error,
text?: string
}
/**
* Component rendering a `span` element containing an error passed to it as props.
*
* May or may not include some text to display to the user.
*/
export const ErrorInline = memo((props: ErrorInlineProps) => {
return (