mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Add proper error message on getUserInfo (#140277)
* Add proper error message on getUserInfo * improved error message on getUserInfo either display the response message or the http status text Co-authored-by: Sven Grossmann <mail@grossmann.dev>
This commit is contained in:
@@ -97,8 +97,18 @@ async function getUserInfo(token: string, serverUri: vscode.Uri, logger: Log): P
|
||||
logger.info('Got account info!');
|
||||
return { id: json.id, accountName: json.login };
|
||||
} else {
|
||||
logger.error(`Getting account info failed: ${result.statusText}`);
|
||||
throw new Error(result.statusText);
|
||||
// either display the response message or the http status text
|
||||
let errorMessage = result.statusText;
|
||||
try {
|
||||
const json = await result.json();
|
||||
if (json.message) {
|
||||
errorMessage = json.message;
|
||||
}
|
||||
} catch (err) {
|
||||
// noop
|
||||
}
|
||||
logger.error(`Getting account info failed: ${errorMessage}`);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user