Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Introduce error boundaries around all screens

+55 -8
+40
src/view/com/util/ErrorBoundary.tsx
··· 1 + import React, {Component, ErrorInfo, ReactNode} from 'react' 2 + import {ErrorScreen} from './error/ErrorScreen' 3 + 4 + interface Props { 5 + children?: ReactNode 6 + } 7 + 8 + interface State { 9 + hasError: boolean 10 + error: any 11 + } 12 + 13 + export class ErrorBoundary extends Component<Props, State> { 14 + public state: State = { 15 + hasError: false, 16 + error: undefined, 17 + } 18 + 19 + public static getDerivedStateFromError(error: Error): State { 20 + return {hasError: true, error} 21 + } 22 + 23 + public componentDidCatch(error: Error, errorInfo: ErrorInfo) { 24 + console.error('Uncaught error:', error, errorInfo) 25 + } 26 + 27 + public render() { 28 + if (this.state.hasError) { 29 + return ( 30 + <ErrorScreen 31 + title="Oh no!" 32 + message="There was an unexpected issue in the application. Please let us know if this happened to you!" 33 + details={this.state.error.toString()} 34 + /> 35 + ) 36 + } 37 + 38 + return this.props.children 39 + } 40 + }
+15 -8
src/view/shell/mobile/index.tsx
··· 31 31 import {Modal} from '../../com/modals/Modal' 32 32 import {Lightbox} from '../../com/lightbox/Lightbox' 33 33 import {Text} from '../../com/util/text/Text' 34 + import {ErrorBoundary} from '../../com/util/ErrorBoundary' 34 35 import {TabsSelector} from './TabsSelector' 35 36 import {Composer} from './Composer' 36 37 import {s, colors} from '../../lib/styles' ··· 327 328 end={{x: 0, y: 1}} 328 329 style={styles.outerContainer}> 329 330 <SafeAreaView style={styles.innerContainer}> 330 - <Login /> 331 + <ErrorBoundary> 332 + <Login /> 333 + </ErrorBoundary> 331 334 </SafeAreaView> 332 335 <Modal /> 333 336 </LinearGradient> ··· 337 340 return ( 338 341 <View style={styles.outerContainer}> 339 342 <View style={styles.innerContainer}> 340 - <Onboard /> 343 + <ErrorBoundary> 344 + <Onboard /> 345 + </ErrorBoundary> 341 346 </View> 342 347 </View> 343 348 ) ··· 400 405 ] 401 406 : undefined, 402 407 ]}> 403 - <Com 404 - params={params} 405 - navIdx={navIdx} 406 - visible={current} 407 - scrollElRef={current ? scrollElRef : undefined} 408 - /> 408 + <ErrorBoundary> 409 + <Com 410 + params={params} 411 + navIdx={navIdx} 412 + visible={current} 413 + scrollElRef={current ? scrollElRef : undefined} 414 + /> 415 + </ErrorBoundary> 409 416 </Animated.View> 410 417 </Screen> 411 418 )