Skip to main content

apk_info/
errors.rs

1//! Errors returned by this crate.
2//!
3//! This module contains the definitions for all error types returned by this crate.
4
5use std::io;
6
7use apk_info_axml::errors::{ARCSError, AXMLError};
8use apk_info_zip::{CertificateError, ZipError};
9use thiserror::Error;
10
11/// Possible `APK` errors
12#[derive(Error, Debug)]
13pub enum APKError {
14    /// Generic I/O error while trying to read or write data
15    #[error(transparent)]
16    IoError(#[from] io::Error),
17
18    /// Got invalid input (for example, empty file or not apk)
19    #[error("got invalid input: {0}")]
20    InvalidInput(&'static str),
21
22    /// Error occurred while parsing `AndroidManifest.xml`
23    #[error("got error while parsing AndroidManifest.xml: {0}")]
24    ManifestError(#[from] AXMLError),
25
26    /// Error occured while parsing `resources.arsc`
27    #[error("got error while parsing resources.arsc: {0}")]
28    ResourceError(#[from] ARCSError),
29
30    #[error("got error while parsing manifest.json inside xapk: {0}")]
31    XAPKManifestError(#[from] serde_json::error::Error),
32
33    /// Error occurred while parsing apk as zip archive
34    #[error("got error while parsing apk archive: {0}")]
35    ZipError(#[from] ZipError),
36
37    #[error("got error while parsing certificates: {0}")]
38    CertificateError(#[from] CertificateError),
39}