)}
))}
>
);
};
const TerriaErrorBox = (props: {
error: TerriaError;
viewState: ViewState;
}) => {
return (
<>
{parseCustomMarkdownToReact(props.error.message, {
viewState: props.viewState,
terria: props.viewState.terria
})}
{Array.isArray(props.error.originalError) &&
props.error.originalError.length > 0 ? (
) : null}
>
);
};
export const terriaErrorNotification = (error: TerriaError) =>
function TerriaErrorNotification(viewState: ViewState) {
// Get "detailed" errors - these can be expanded if the user wants to see more "detail"
let detailedErrors: (Error | TerriaError)[] | undefined;
// If the top level error is the highestImportanceError, then don't show it in detailedErrors (as it will just duplicate the top level error message)
if (error.message !== error.highestImportanceError.message) {
detailedErrors = [error];
} else if (error.originalError) {
detailedErrors = Array.isArray(error.originalError)
? error.originalError
: [error.originalError];
}
// We only show FeedbackLink if the error message doesn't include the custom component (so we don't get duplicates)
const includesFeedbackLink = error.highestImportanceError.message.includes(
`<${FeedbackLinkCustomComponent.componentName}`
);
return (
<>
p.theme.textLight};
}
`}
textLight
>
{parseCustomMarkdownToReact(error.highestImportanceError.message, {
viewState: viewState,
terria: viewState.terria
})}
{/* Show error details if there are more errors to show */}
{detailedErrors ? (
<>
{
runInAction(() => (error.showDetails = show));
return false;
}}
>
>
) : null}
{!includesFeedbackLink ? : null}
>
);
};