mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Let's log every potential failure (#10342)
* Let's log every potential failure * Add more context to the error
This commit is contained in:
@@ -225,7 +225,6 @@ export abstract class AzureAuth implements vscode.Disposable {
|
|||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.log(`Could not refresh access token for ${JSON.stringify(tenant)} - silently removing the tenant from the user's account.`);
|
console.log(`Could not refresh access token for ${JSON.stringify(tenant)} - silently removing the tenant from the user's account.`);
|
||||||
azureAccount.properties.tenants = azureAccount.properties.tenants.filter(t => t.id !== tenant.id);
|
azureAccount.properties.tenants = azureAccount.properties.tenants.filter(t => t.id !== tenant.id);
|
||||||
console.log(ex, ex?.data, ex?.response);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,28 +271,40 @@ export abstract class AzureAuth implements vscode.Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async makePostRequest(uri: string, postData: { [key: string]: string }, validateStatus = false) {
|
protected async makePostRequest(uri: string, postData: { [key: string]: string }, validateStatus = false) {
|
||||||
const config: AxiosRequestConfig = {
|
try {
|
||||||
headers: {
|
const config: AxiosRequestConfig = {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (validateStatus) {
|
||||||
|
config.validateStatus = () => true;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if (validateStatus) {
|
return await axios.post(uri, qs.stringify(postData), config);
|
||||||
config.validateStatus = () => true;
|
} catch (ex) {
|
||||||
|
console.log('Unexpected error making Azure auth request', 'azureCore.postRequest', JSON.stringify(ex?.response?.data, undefined, 2));
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return axios.post(uri, qs.stringify(postData), config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async makeGetRequest(token: string, uri: string): Promise<AxiosResponse<any>> {
|
protected async makeGetRequest(token: string, uri: string): Promise<AxiosResponse<any>> {
|
||||||
const config = {
|
try {
|
||||||
headers: {
|
const config = {
|
||||||
Authorization: `Bearer ${token}`,
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
'Content-Type': 'application/json',
|
||||||
};
|
},
|
||||||
|
};
|
||||||
|
|
||||||
return axios.get(uri, config);
|
return await axios.get(uri, config);
|
||||||
|
} catch (ex) {
|
||||||
|
// Intercept and print error
|
||||||
|
console.log('Unexpected error making Azure auth request', 'azureCore.getRequest', JSON.stringify(ex?.response?.data, undefined, 2));
|
||||||
|
// rethrow error
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getTenants(token: AccessToken): Promise<Tenant[]> {
|
protected async getTenants(token: AccessToken): Promise<Tenant[]> {
|
||||||
@@ -325,7 +336,6 @@ export abstract class AzureAuth implements vscode.Disposable {
|
|||||||
return tenants;
|
return tenants;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.log(ex);
|
console.log(ex);
|
||||||
console.log(JSON.stringify(ex?.response?.data, undefined, 2));
|
|
||||||
throw new Error('Error retreiving tenant information');
|
throw new Error('Error retreiving tenant information');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ export class AzureDeviceCode extends AzureAuth {
|
|||||||
return result;
|
return result;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.log(ex);
|
console.log(ex);
|
||||||
|
console.log('Unexpected error making Azure auth request', 'azureCore.checkForResult', JSON.stringify(ex?.response?.data, undefined, 2));
|
||||||
throw new Error(msg);
|
throw new Error(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user