Skip to content

Commit 2696f20

Browse files
committed
fix: add azure error
1 parent d7f54fa commit 2696f20

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/cmap/auth/mongodb_oidc/azure_service_workflow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MongoAWSError, MongoMissingCredentialsError } from '../../../error';
1+
import { MongoAzureError } from '../../../error';
22
import { request } from '../../../utils';
33
import { AzureTokenCache } from './azure_token_cache';
44
import { ServiceWorkflow } from './service_workflow';
@@ -51,7 +51,7 @@ export class AzureServiceWorkflow extends ServiceWorkflow {
5151
async getToken(): Promise<string> {
5252
const tokenAudience = process.env.TOKEN_AUDIENCE;
5353
if (!tokenAudience) {
54-
throw new MongoAWSError(TOKEN_AUDIENCE_MISSING_ERROR);
54+
throw new MongoAzureError(TOKEN_AUDIENCE_MISSING_ERROR);
5555
}
5656
let token;
5757
const entry = this.cache.getEntry(tokenAudience);
@@ -66,7 +66,7 @@ export class AzureServiceWorkflow extends ServiceWorkflow {
6666

6767
if (isEndpointResultInvalid(token)) {
6868
this.cache.deleteEntry(tokenAudience);
69-
throw new MongoMissingCredentialsError(ENDPOINT_RESULT_ERROR);
69+
throw new MongoAzureError(ENDPOINT_RESULT_ERROR);
7070
}
7171
return token;
7272
}

src/error.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,23 @@ export class MongoAWSError extends MongoRuntimeError {
373373
}
374374
}
375375

376+
/**
377+
* A error generated when the user attempts to authenticate
378+
* via Azure, but fails.
379+
*
380+
* @public
381+
* @category Error
382+
*/
383+
export class MongoAzureError extends MongoRuntimeError {
384+
constructor(message: string) {
385+
super(message);
386+
}
387+
388+
override get name(): string {
389+
return 'MongoAzureError';
390+
}
391+
}
392+
376393
/**
377394
* An error generated when a ChangeStream operation fails to execute.
378395
*

0 commit comments

Comments
 (0)