| Name | Message | Date |
|---|---|---|
| 📁 ui | 10 hours ago | |
| 📄 api.ts | 10 hours ago | |
| 📄 auth.ts | 10 hours ago | |
| 📄 content.ts | 10 hours ago | |
| 📄 errors.ts | 10 hours ago | |
| 📄 hash.ts | 10 hours ago | |
| 📄 md5.ts | 10 hours ago | |
| 📄 selectors.ts | 10 hours ago | |
| 📄 titles.ts | 10 hours ago |
📄
src/errors.ts
export type FailureReason =
'not-logged-in' | 'session-expired' | 'network' | 'popup-blocked' | 'server' | 'unknown';
/** An error that should be reported to the user with a Swedish message. */
export class DownloadError extends Error {
readonly reason: FailureReason;
readonly detail?: string;
constructor(reason: FailureReason, detail?: string) {
super(detail ?? reason);
this.name = 'DownloadError';
this.reason = reason;
this.detail = detail;
}
}
/** The user closed the loading tab — not an error, just stop quietly. */
export class CancelledError extends Error {
constructor() {
super('cancelled by user');
this.name = 'CancelledError';
}
}
/** Map any thrown value onto a user-facing failure reason. */
export function toFailureReason(error: unknown): FailureReason {
if (error instanceof DownloadError) return error.reason;
if (error instanceof TypeError) return 'network'; // fetch() network failure
return 'unknown';
}