Skip to content

Commit

Permalink
Update SectionError component to render error root causes correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed May 14, 2021
1 parent 1a3ee00 commit e0b22af
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ import { EuiCallOut, EuiSpacer } from '@elastic/eui';
export function SectionError(props) {
const { title, error, ...rest } = props;
const data = error.body ? error.body : error;
const {
error: errorString,
attributes, // wrapEsError() on the server add a "cause" array
message,
} = data;
const { error: errorString, attributes, message } = data;

return (
<EuiCallOut title={title} color="danger" iconType="alert" {...rest}>
<div>{message || errorString}</div>
{attributes && attributes.cause && (
{attributes?.error?.root_cause && (
<Fragment>
<EuiSpacer size="m" />
<ul>
{attributes.cause.map((message, i) => (
<li key={i}>{message}</li>
{attributes.error.root_cause.map(({ type, reason }, i) => (
<li key={i}>
{type}: {reason}
</li>
))}
</ul>
</Fragment>
Expand Down

0 comments on commit e0b22af

Please sign in to comment.