Skip to content

Commit 6280b96

Browse files
committed
Improved error codes/messages consistency
1 parent f3fe773 commit 6280b96

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/Logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function logMessage(type: string, info: LogInfo): void {
2121
break;
2222
case 'error':
2323
if (!disabledLogs.errors) {
24-
console.error(`%c${info.code}:%c ${info.message}`, info.error || '');
24+
console.error(`${info.code}: ${info.message}`, info.error || '');
2525
}
2626
break;
2727
default:

src/Oauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export async function initializeOauthSession(domain: string): Promise<string> {
7474

7575
return session?.data.key;
7676
} catch {
77-
throw new AuthenticatorError('ERR_SESSION', 'Error generating session.');
77+
throw new AuthenticatorError('ERR_AUTH_SESSION', 'Error generating session.');
7878
}
7979
}
8080

src/Popup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class Popup {
8888
);
8989

9090
if (!popUp) {
91-
throw new AuthenticatorError('ERR_POPUP_BLOCKED', 'Popup is blocked. Make sure to enable popups.');
91+
throw new AuthenticatorError('ERR_AUTH_POPUP_BLOCKED', 'Popup is blocked. Make sure to enable popups.');
9292
}
9393

9494
return popUp;
@@ -139,6 +139,6 @@ export class Popup {
139139
return;
140140
}
141141

142-
throw new AuthenticatorError('ERR_POPUP_CLOSED', 'Popup is closed.');
142+
throw new AuthenticatorError('ERR_AUTH_POPUP_CLOSED', 'Popup is closed.');
143143
}
144144
}

src/Utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function httpCall<JsonResponse>(url: string, init?: RequestInit): P
3232
if (response.status >= 200 && response.status <= 299) {
3333
return (await response.json()) as JsonResponse;
3434
}
35-
throw new AuthenticatorError('ERR_HTTP_REQUEST', response.statusText);
35+
throw new AuthenticatorError('ERR_AUTH_HTTP_REQUEST', response.statusText);
3636
})
3737
.then((response: JsonResponse): JsonResponse => {
3838
return response;
@@ -42,7 +42,7 @@ export async function httpCall<JsonResponse>(url: string, init?: RequestInit): P
4242
throw error;
4343
}
4444

45-
throw new AuthenticatorError('ERR_HTTP_REQUEST', error);
45+
throw new AuthenticatorError('ERR_AUTH_HTTP_REQUEST', error);
4646
});
4747
}
4848

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function authorize(
5858
})
5959
.catch((error) => {
6060
if (error === false) {
61-
throw new AuthenticatorError('ERR_DOMAIN_POPUP_CLOSED', 'Domain cancelled by client.');
61+
throw new AuthenticatorError('ERR_AUTH_DOMAIN_POPUP_CLOSED', 'Domain cancelled by client.');
6262
}
6363

6464
throw new AuthenticatorError('ERR_AUTH_FAILED', 'Auth failed.');

0 commit comments

Comments
 (0)