mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +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:
parent
88106d2a6d
commit
22e45e9f88
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue