Skip to content

Add OAuth2Error class and corresponding tests #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions workers/main/src/common/errors/OAuth2Error.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { describe, expect, it } from 'vitest';

import { OAuth2Error } from './OAuth2Error';

describe('OAuth2Error', () => {
it('should set the message, name, and default error code', () => {
const err = new OAuth2Error('test message');

expect(err.message).toBe('test message');
expect(err.name).toBe('OAuth2Error');
expect(err.code).toBe('UNKNOWN_OAUTH2_ERROR');
});

it('should set the message, name, and custom error code', () => {
const err = new OAuth2Error('test message', 'CUSTOM_ERROR');

expect(err.message).toBe('test message');
expect(err.name).toBe('OAuth2Error');
expect(err.code).toBe('CUSTOM_ERROR');
});
});
10 changes: 10 additions & 0 deletions workers/main/src/common/errors/OAuth2Error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AppError } from './AppError';

export class OAuth2Error extends AppError {
public readonly code: string;

constructor(message: string, code: string = 'UNKNOWN_OAUTH2_ERROR') {
super(message, 'OAuth2Error');
this.code = code;
}
}
1 change: 1 addition & 0 deletions workers/main/src/common/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './AppError';
export * from './FileUtilsError';
export * from './FinAppRepositoryError';
export * from './OAuth2Error';
export * from './QuickBooksRepositoryError';
export * from './SlackRepositoryError';
export * from './TargetUnitRepositoryError';