import { IParsedError , parseError } from "vscode-azureextensionui" ; import { ext } from "../extensionVariables" ; export function errorUtil ( responseBody ) { let msg = "" ; const errors = JSON . parse ( responseBody ) ; errors . error . details . forEach ( ( element ) => { msg = msg . concat ( `Error: "${ element . code }" - "${ element . message }" \n` ) ; } ) ; return msg ; } export function processError ( error , message ) { ext . outputChannel . appendLine ( error ) ; try { const err = parseError ( error ) ; message = err . message ; if ( err . errorType . toLowerCase ( ) === 'validationerror' ) { message = errorUtil ( error . response . body ) ; } } catch ( e ) { ext . outputChannel . appendLine ( "Could not parse error." ) ; } ext . outputChannel . appendLine ( message ) ; ext . outputChannel . show ( ) ; return message ; }