import { observable , action , makeObservable } from 'mobx' ; import { DetailsError } from './DetailsError' ; export class GQLErrorCatcher { hasDetails = false ; responseMessage : string | null = null ; exception : DetailsError | null = null ; constructor ( ) { makeObservable ( this , { hasDetails : observable , responseMessage : observable , exception : observable , catch : action , clear : action , } ) ; } catch ( exception ) { if ( exception instanceof DetailsError ) { this . responseMessage = exception . errorMessage ; this . hasDetails = exception . hasDetails ( ) ; this . exception = exception ; return true ; } this . clear ( ) ; return false ; } clear ( ) { this . hasDetails = false ; this . responseMessage = null ; this . exception = null ; } }