diff --git a/src/notifications/UnexpectedErrorNotification.scss b/src/notifications/UnexpectedErrorNotification.scss new file mode 100644 index 00000000..c0ac8343 --- /dev/null +++ b/src/notifications/UnexpectedErrorNotification.scss @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2022 The Pybricks Authors + +@import '../variables.scss'; + +pre.pb-notification-stack-trace { + max-width: $pt-grid-size * 50; + max-height: $pt-grid-size * 50; + overflow: auto; +} diff --git a/src/notifications/UnexpectedErrorNotification.tsx b/src/notifications/UnexpectedErrorNotification.tsx index 62b90207..66705e38 100644 --- a/src/notifications/UnexpectedErrorNotification.tsx +++ b/src/notifications/UnexpectedErrorNotification.tsx @@ -3,9 +3,11 @@ // Provides special notification contents for unexpected errors. -import { AnchorButton, Button, ButtonGroup, Intent } from '@blueprintjs/core'; +import './UnexpectedErrorNotification.scss'; +import { AnchorButton, Button, ButtonGroup, Collapse, Intent } from '@blueprintjs/core'; import { useI18n } from '@shopify/react-i18n'; -import React from 'react'; +import React, { useState } from 'react'; +import { useUniqueId } from '../utils/react'; import { I18nId } from './i18n'; type UnexpectedErrorNotificationProps = { @@ -18,10 +20,25 @@ const UnexpectedErrorNotification: React.VoidFunctionComponent< > = ({ messageId, err }) => { // istanbul ignore next: babel-loader rewrites this line const [i18n] = useI18n(); + const [isExpanded, setIsExpanded] = useState(false); + const labelId = useUniqueId('pb-notification'); return ( <>
{i18n.translate(messageId, { errorMessage: err.message })}
+ + +{err.stack}
+