diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-04-22 22:07:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-22 22:07:48 +0100 |
commit | f4e72cc83c431285dee454b6201377871dbed09a (patch) | |
tree | 33a0aba2bab717c1380c96e4b7295c6e005a1c6e /src/view/com/util/ErrorBoundary.tsx | |
parent | 27c4054fcb885d8e00a466b4bd416edfe6eca32c (diff) | |
download | voidsky-f4e72cc83c431285dee454b6201377871dbed09a.tar.zst |
[GIFs] Add error boundary to GIF picker (#3643)
* error boundary on gif picker * add dialog.close for web users * fix size of dialog on web * Safer coercion --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/view/com/util/ErrorBoundary.tsx')
-rw-r--r-- | src/view/com/util/ErrorBoundary.tsx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/view/com/util/ErrorBoundary.tsx b/src/view/com/util/ErrorBoundary.tsx index 22fdd606e..dccd2bbc9 100644 --- a/src/view/com/util/ErrorBoundary.tsx +++ b/src/view/com/util/ErrorBoundary.tsx @@ -1,12 +1,14 @@ import React, {Component, ErrorInfo, ReactNode} from 'react' -import {ErrorScreen} from './error/ErrorScreen' -import {CenteredView} from './Views' import {msg} from '@lingui/macro' -import {logger} from '#/logger' import {useLingui} from '@lingui/react' +import {logger} from '#/logger' +import {ErrorScreen} from './error/ErrorScreen' +import {CenteredView} from './Views' + interface Props { children?: ReactNode + renderError?: (error: any) => ReactNode } interface State { @@ -30,6 +32,10 @@ export class ErrorBoundary extends Component<Props, State> { public render() { if (this.state.hasError) { + if (this.props.renderError) { + return this.props.renderError(this.state.error) + } + return ( <CenteredView style={{height: '100%', flex: 1}}> <TranslatedErrorScreen details={this.state.error.toString()} /> |