Skip to content

Commit

Permalink
feat(web): prettify call stack in error popup
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed May 11, 2022
1 parent afae90e commit a512e69
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export const Message = styled.p`
word-break: normal;
`

const Stack = styled.pre`
white-space: pre-wrap;
`

export function getErrorDetails(error: unknown): {
name: string
message: string
Expand Down Expand Up @@ -76,7 +80,9 @@ export function GenericError({ error }: { error: Error | string }) {
<ErrorContainer>
<h5>{errorText}</h5>
<Message>{message}</Message>
{process.env.NODE_ENV === 'development' && stack && <p>{stack}</p>}
{process.env.NODE_ENV === 'development' && stack && (
<Stack>{stack.replace(/webpack-internal:\/{3}\.\//g, '').replace(/https?:\/\/(.+):\d+\//g, '')}</Stack>
)}
</ErrorContainer>
)
}
Expand Down

0 comments on commit a512e69

Please sign in to comment.