Page MenuHomePhabricator

Improve error handling
Closed, DuplicatePublic

Description

In some places we are fetching errors like this:

const explanation = ( 'statusCode' in failure ) ? failure.response.statusText : failure;
this._vm.$notify.error( i18n.t( 'apierror', [ explanation ] ) );

in other places as stated below:

const data = getFailurePayload( failure );
for ( const err in data.errors )    {
        this._vm.$notify.error(
            i18n.t( 'apierrors', [
                data.errors[ err ].field,
                data.errors[ err ].message
            ] )
     );
}

And, we have a bunch of translation strings that the notify plugin uses:

  • "apierror": "Oops! An error occurred: $1",
  • "apierrors": "Oops! An error occured in $1: $2",
  • "auditlogs-apierror": "Error fetching page $1: $2",
  • "developersettings-appupdateerror": "An error occurred while updating the app with client id '$1'",
  • "editformerror": "Oops! '$1' error occured in '$2': $3"

Ideally:

  • There is one consistent way to fetch errors, perhaps using the getFailurePayload method.
  • The display logic around showing errors in .js files moved to a central location to avoid code duplication.
  • There is one translation string (atleast for errors) that we stick to.

Event Timeline

srishakatux renamed this task from Improve error handling-rely on a more consistent means to fetch and display errors. to Improve error handling.Apr 14 2021, 1:20 AM