Skip to content
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
14 changes: 14 additions & 0 deletions src/renderer/utils/api/errors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AxiosError, type AxiosResponse } from 'axios';

import { EVENTS } from '../../../shared/events';

import type { Link } from '../../types';
import type { GitHubRESTError } from '../../typesGitHub';
import { Errors } from '../errors';
Expand Down Expand Up @@ -93,6 +95,18 @@ describe('renderer/utils/api/errors.ts', () => {
});
});

it('bad credentials - safe storage', async () => {
const mockError: Partial<AxiosError<GitHubRESTError>> = {
message: `Error invoking remote method '${EVENTS.SAFE_STORAGE_DECRYPT}': Error: Error while decrypting the ciphertext provided to safeStorage.decryptString. Ciphertext does not appear to be encrypted.`,
};

const result = determineFailureType(
mockError as AxiosError<GitHubRESTError>,
);

expect(result).toBe(Errors.BAD_CREDENTIALS);
});

it('unknown error', async () => {
const mockError: Partial<AxiosError<GitHubRESTError>> = {
code: 'anything',
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/utils/api/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export function determineFailureType(
return Errors.NETWORK;
}

if (err.message?.includes('safeStorage')) {
return Errors.BAD_CREDENTIALS;
}

if (code !== AxiosError.ERR_BAD_REQUEST) {
return Errors.UNKNOWN;
}
Expand Down
Loading