From b49631d6163fb47faa39d77e3b691a618625b775 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Mon, 30 Nov 2020 13:25:16 -0600 Subject: [PATCH 1/2] build error message from Error subparts --- src/components/error_boundary/error_boundary.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/error_boundary/error_boundary.tsx b/src/components/error_boundary/error_boundary.tsx index 9436aae5e49..dd01f129086 100644 --- a/src/components/error_boundary/error_boundary.tsx +++ b/src/components/error_boundary/error_boundary.tsx @@ -25,7 +25,7 @@ import { EuiText } from '../text'; interface EuiErrorBoundaryState { hasError: boolean; - error?: Error; + error?: string; } export type EuiErrorBoundaryProps = CommonProps & @@ -55,8 +55,14 @@ export class EuiErrorBoundary extends Component< this.state = errorState; } - componentDidCatch(error: Error) { + componentDidCatch({ message, stack }: Error) { // Display fallback UI + // Only Chrome includes the `message` property as part of `stack`. + // For consistency, rebuild the full error text from the Error subparts. + const idx = stack?.indexOf(message) || -1; + const stackStr = idx > -1 ? stack?.substr(idx + message.length + 1) : stack; + const error = `Error: ${message} +${stackStr}`; this.setState({ hasError: true, error, @@ -74,7 +80,7 @@ export class EuiErrorBoundary extends Component<

Error

-                

{this.state.error && this.state.error.stack}

+

{this.state.error}

From 6f74acbf0bda040d71a4cc007ebf6b112d8f3be3 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Tue, 1 Dec 2020 15:01:24 -0600 Subject: [PATCH 2/2] CL --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8b680fe993..1494e0b184c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `30.5.1`. +**Bug fixes** + +- Expose `EuiErrorBoundary` error message not showing in non-Chromium browsers ([#4324](https://github.com/elastic/eui/pull/4324)) ## [`30.5.1`](https://github.com/elastic/eui/tree/v30.5.1)