Skip to main content

assetpack_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5  #[error(transparent)]
6  Io(#[from] std::io::Error),
7  #[cfg(feature = "sqlite")]
8  #[error(transparent)]
9  Sql(#[from] sqlx::Error),
10  #[error("invalid hash length: {0}, expected 32 bytes")]
11  InvalidHashLength(usize),
12  #[error("invalid hex encoding: {0}")]
13  InvalidHex(String),
14  #[error("invalid fastcdc parameters")]
15  InvalidCdcParams,
16  #[error("compress failed: {0}")]
17  Compress(String),
18  #[error("decompress failed: {0}")]
19  Decompress(String),
20  #[error("invalid codec value {0}")]
21  InvalidCodec(String),
22  #[error("merkle meta missing {0}")]
23  MissingMeta(String),
24  #[error("hash mismatch when writing object")]
25  HashMismatch,
26  #[error("object decoded length mismatch: expected {expected}, got {actual}")]
27  ObjectLengthMismatch { expected: u64, actual: u64 },
28  #[error("object hash mismatch: expected {expected}, got {actual}")]
29  ObjectHashMismatch { expected: crate::Hash32, actual: crate::Hash32 },
30  #[error("sqlite integrity_check failed: {0}")]
31  Integrity(String),
32  #[error("object not found")]
33  ObjectNotFound,
34  #[error("invalid config: {0}")]
35  InvalidConfig(String),
36  #[error("generic error: {0}")]
37  Other(String),
38  #[error("invalid sealed pack: {0}")]
39  InvalidSealed(String),
40  #[error("sealed pack authentication failed")]
41  AuthenticationFailed,
42  #[error("duplicate transform decoder {id} version {version}")]
43  DuplicateTransformDecoder { id: u16, version: u16 },
44  #[error("unsupported transform {id} version {version}")]
45  UnsupportedTransform { id: u16, version: u16 },
46  #[error("object {hash} has kind {actual:?}, expected {expected:?}")]
47  ObjectKindMismatch {
48    hash: crate::Hash32,
49    expected: crate::ObjectKind,
50    actual: crate::ObjectKind,
51  },
52  #[error("recipe chunk {hash} length mismatch: expected {expected}, got {actual}")]
53  RecipeChunkLengthMismatch { hash: crate::Hash32, expected: u64, actual: u64 },
54  #[error("invalid recipe: {0}")]
55  InvalidRecipe(String),
56  #[error("file read limit {limit} exceeded: maximum {maximum}, actual {actual}")]
57  FileReadLimitExceeded { limit: &'static str, maximum: u64, actual: u64 },
58  #[error("unable to allocate {requested} bytes for {buffer}")]
59  FileReadAllocationFailed { buffer: &'static str, requested: u64 },
60  #[error("original file mismatch")]
61  OriginalFileMismatch {
62    expected_size: u64,
63    actual_size: u64,
64    expected_hash: crate::Hash32,
65    actual_hash: crate::Hash32,
66  },
67}
68
69pub type Result<T> = std::result::Result<T, Error>;