mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix azure auth error display (#18110)
* Fix azure auth error display * Don't localize command * Only show localized error string
This commit is contained in:
@@ -103,11 +103,12 @@ export abstract class AzureAuth implements vscode.Disposable {
|
||||
if (ex instanceof AzureAuthError) {
|
||||
if (loginComplete) {
|
||||
loginComplete.reject(ex);
|
||||
Logger.error(ex);
|
||||
} else {
|
||||
void vscode.window.showErrorMessage(ex.getPrintableString());
|
||||
void vscode.window.showErrorMessage(ex.message);
|
||||
Logger.error(ex.originalMessageAndException);
|
||||
}
|
||||
}
|
||||
Logger.error(ex);
|
||||
return {
|
||||
canceled: false
|
||||
};
|
||||
@@ -139,9 +140,11 @@ export abstract class AzureAuth implements vscode.Disposable {
|
||||
return await this.hydrateAccount(tokenResult, this.getTokenClaims(tokenResult.token));
|
||||
} catch (ex) {
|
||||
if (ex instanceof AzureAuthError) {
|
||||
void vscode.window.showErrorMessage(ex.getPrintableString());
|
||||
void vscode.window.showErrorMessage(ex.message);
|
||||
Logger.error(ex.originalMessageAndException);
|
||||
} else {
|
||||
Logger.error(ex);
|
||||
}
|
||||
Logger.error(ex);
|
||||
account.isStale = true;
|
||||
return account;
|
||||
}
|
||||
@@ -261,7 +264,7 @@ export abstract class AzureAuth implements vscode.Disposable {
|
||||
|
||||
if (response.data.error) {
|
||||
Logger.error('Response error!', response.data);
|
||||
throw new AzureAuthError(localize('azure.responseError', "Token retrieval failed with an error. Open developer tools to view the error"), 'Token retrieval failed', undefined);
|
||||
throw new AzureAuthError(localize('azure.responseError', "Token retrieval failed with an error. [Open developer tools]({0}) for more details.", 'command:workbench.action.toggleDevTools'), 'Token retrieval failed', undefined);
|
||||
}
|
||||
|
||||
const accessTokenString = response.data.access_token;
|
||||
|
||||
@@ -4,18 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export class AzureAuthError extends Error {
|
||||
private readonly _originalMessage: string;
|
||||
|
||||
constructor(localizedMessage: string, _originalMessage: string, private readonly originalException: any) {
|
||||
constructor(localizedMessage: string, public readonly originalMessage: string, private readonly originalException: any) {
|
||||
super(localizedMessage);
|
||||
|
||||
}
|
||||
|
||||
get originalMessage(): string {
|
||||
return this._originalMessage;
|
||||
}
|
||||
|
||||
getPrintableString(): string {
|
||||
/**
|
||||
* The original message and exception for displaying extra information
|
||||
*/
|
||||
public get originalMessageAndException(): string {
|
||||
return JSON.stringify({
|
||||
originalMessage: this.originalMessage,
|
||||
originalException: this.originalException
|
||||
|
||||
Reference in New Issue
Block a user