streaming 7-Zip archive extractor
1/**
2 * @module
3 *
4 * errors thrown by the 7z library. every error is an instance of
5 * {@link SevenZipError}, so callers can branch with `instanceof`.
6 */
7
8/** base class for every error thrown by the 7z library. */
9export class SevenZipError extends Error {
10 override name: string = 'SevenZipError';
11}
12
13/** stored data did not match a CRC32 recorded in the archive. */
14export class ChecksumMismatchError extends SevenZipError {
15 override name: string = 'ChecksumMismatchError';
16}
17
18/**
19 * a password was supplied but does not match the archive's stored check
20 * value. the caller can re-prompt and retry with a different password.
21 */
22export class InvalidPasswordError extends SevenZipError {
23 override name: string = 'InvalidPasswordError';
24}
25
26/** the source bytes do not begin with a recognized 7z signature. */
27export class InvalidSignatureError extends SevenZipError {
28 override name: string = 'InvalidSignatureError';
29}
30
31/** the archive's structure is corrupt or violates the format spec; no retry will help. */
32export class MalformedArchiveError extends SevenZipError {
33 override name: string = 'MalformedArchiveError';
34}
35
36/**
37 * the archive (or one of its entries) is encrypted but no password was
38 * supplied. the caller can prompt the user and retry with a password.
39 */
40export class MissingPasswordError extends SevenZipError {
41 override name: string = 'MissingPasswordError';
42}
43
44/**
45 * the underlying {@link Reader} failed to deliver bytes. distinct from
46 * {@link TruncatedArchiveError}, which fires when the reader succeeds but
47 * the archive itself ends mid-structure.
48 */
49export class ReaderError extends SevenZipError {
50 override name: string = 'ReaderError';
51}
52
53/** the archive ends in the middle of a structure. */
54export class TruncatedArchiveError extends SevenZipError {
55 override name: string = 'TruncatedArchiveError';
56}
57
58/** the archive uses a feature this library does not implement yet. */
59export class UnsupportedFeatureError extends SevenZipError {
60 override name: string = 'UnsupportedFeatureError';
61}