import { CommandCallback , IActionContext , IParsedError , parseError , registerCommand } from 'vscode-azureextensionui' ; import { localize } from './localize' ; /**
 * Use this to get extra error handling for commands that interact directly with site APIs.
 */ export function registerSiteCommand ( commandId , callback , debounce ? ) { registerCommand ( commandId , async ( context , ... args ) => { try { return await Promise . resolve ( callback ( context , ... args ) ) ; } catch ( error ) { handleSiteErrors ( context , error ) ; } } , debounce ) ; } function handleSiteErrors ( context , error ) { const parsedError = parseError ( error ) ; if ( parsedError . errorType === '502' || parsedError . errorType === '503' ) { context . errorHandling . suppressReportIssue = true ; const troubleshooting = localize ( '502or503Troubleshooting' , 'View troubleshooting tips [here](https://aka.ms/AA772mm).' ) ; throw new Error ( `${ parsedError . message } ${ troubleshooting }` ) ; } else { throw error ; } }