Skip to content

Commit

Permalink
chore: add instalce offline error
Browse files Browse the repository at this point in the history
  • Loading branch information
Benmuiruri committed Feb 20, 2025
1 parent 413dda3 commit f565427
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/authentication-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ export class AuthError extends Error {
static CANNOT_PARSE_CHT_VERSION(chtCoreVersion: string, domain: string) {
return new AuthError(`Cannot parse cht core version ${chtCoreVersion} for instance "${domain}"`);
}

static INSTANCE_OFFLINE() {
return new AuthError(`Unable to connect to instance. Please check instance availability.`);
}
}
3 changes: 3 additions & 0 deletions src/lib/cht-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ export default class ChtSession {
if (e?.response?.status === 401) {
throw AuthError.INVALID_CREDENTIALS();
}
if (e.code === 'ENOTFOUND' || e.errno === -3008) {
throw AuthError.INSTANCE_OFFLINE();
}
throw e;
}
}
Expand Down

0 comments on commit f565427

Please sign in to comment.