'use strict' ; import * as vscode from 'vscode' ; import { IError } from './../spgo' ; import { Logger } from '../util/logger' ; export class ErrorHelper { static handleError ( err , suppressError ? ) { if ( suppressError ) { Logger . outputError ( err , vscode . window . spgo . outputChannel ) ; } else { if ( err . message && ( err . message . indexOf ( 'wst:FailedAuthentication' ) >= 0 || err . message . indexOf ( 'Unable to resolve namespace authentication type' ) >= 0 ) ) { vscode . window . spgo . credentials = null ; let error = { message : 'Invalid user credentials. Please reset your credentials via the command menu and try again.' } ; Logger . showError ( error . message , err ) ; } else if ( err . message === 'Response code 423 (Locked)' ) { Logger . showError ( 'This file is not checked out to you. Please check out the file before editing.' , err ) ; } else { if ( err . message && err . message . value ) { Logger . showError ( err . message . value , err ) ; } else if ( err . error && err . error . error ) { Logger . showError ( err . error . error . message . value , err ) ; } else { Logger . outputError ( err , vscode . window . spgo . outputChannel ) ; } } } } }