Skip to content

Commit

Permalink
[identity] Only set error.cause if it exists (Azure#30629)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR

@azure/identity 

### Issues associated with this PR

N/A

### Describe the problem that is addressed by this PR

A minor cosmetic fix where we only set `cause` if it exists in the
options.
Before this change, node would print `[cause]: undefined` which can be
misleading. 

Now, we'll omit `cause` entirely if its not set.
  • Loading branch information
maorleger authored Aug 5, 2024
1 parent 7b6d6fe commit 0ee273f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions sdk/identity/identity/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ export class AuthenticationRequiredError extends Error {
super(
options.message,
// @ts-expect-error - TypeScript does not recognize this until we use ES2022 as the target; however, all our major runtimes do support the `cause` property
{
cause: options.cause,
},
options.cause ? { cause: options.cause } : undefined,
);
this.scopes = options.scopes;
this.getTokenOptions = options.getTokenOptions;
Expand Down

0 comments on commit 0ee273f

Please sign in to comment.