diff --git a/packages/react-components/src/ErrorBoundary.tsx b/packages/react-components/src/ErrorBoundary.tsx index 4c21d8a74a..9c7f1f50ba 100644 --- a/packages/react-components/src/ErrorBoundary.tsx +++ b/packages/react-components/src/ErrorBoundary.tsx @@ -20,6 +20,14 @@ interface State { prevTrigger: string | null; } +function formatStack (stack = ''): React.ReactElement | null { + return ( + <>{stack.split('\n').map((line, index) => +
{line}
+ )} + ); +} + // NOTE: This is the only way to do an error boundary, via extend class ErrorBoundary extends React.Component { public override state: State = { error: null, prevTrigger: null }; @@ -56,7 +64,7 @@ class ErrorBoundary extends React.Component {

{t('Uncaught error. Something went wrong with the query and rendering of this component. Please supply all the details below when logging an issue, it may help in tracing the cause.')}

{displayError.message}

-

{displayError.stack}

+ {formatStack(displayError.stack)}
) : children; diff --git a/packages/react-hooks/src/useNamedHook.ts b/packages/react-hooks/src/useNamedHook.ts index 7a5550968f..cebb0e1d62 100644 --- a/packages/react-hooks/src/useNamedHook.ts +++ b/packages/react-hooks/src/useNamedHook.ts @@ -1,7 +1,7 @@ // Copyright 2017-2021 @polkadot/react-hooks authors & contributors // SPDX-License-Identifier: Apache-2.0 -export function useNamedHook (name: string, fn: (...args: any[]) => T, ...args: unknown[]): T { +export function useNamedHook T> (name: string, fn: F, ...args: Parameters): T { try { return fn(...args); } catch (error) {