Skip to main content

ndk_build2/
error.rs

1use {
2    std::{
3        io::Error as IoError, num::ParseIntError, path::PathBuf, process::Command, str::Utf8Error,
4    },
5    thiserror::Error,
6};
7
8#[derive(Debug, Error)]
9pub enum NdkError {
10    #[error(
11        "Android SDK is not found. \
12    Please set the path to the Android SDK with the $ANDROID_HOME \
13    environment variable."
14    )]
15    SdkNotFound,
16    #[error(
17        "Android NDK is not found. \
18        Please set the path to the Android NDK with $ANDROID_NDK_ROOT \
19        environment variable."
20    )]
21    NdkNotFound,
22    #[error(
23        "GNU toolchain binary `{gnu_bin}` nor LLVM toolchain binary `{llvm_bin}` found in `{toolchain_path:?}`."
24    )]
25    ToolchainBinaryNotFound {
26        toolchain_path: PathBuf,
27        gnu_bin: String,
28        llvm_bin: String,
29    },
30    #[error("Path `{0:?}` doesn't exist.")]
31    PathNotFound(PathBuf),
32    #[error("Command `{0}` not found.")]
33    CmdNotFound(String),
34    #[error("Android SDK has no build tools.")]
35    BuildToolsNotFound,
36    #[error("Android SDK has no platforms installed.")]
37    NoPlatformFound,
38    #[error("Platform `{0}` is not installed.")]
39    PlatformNotFound(u32),
40    #[error("Target is not supported.")]
41    UnsupportedTarget,
42    #[error("Host `{0}` is not supported.")]
43    UnsupportedHost(String),
44    #[error(transparent)]
45    Io(#[from] IoError),
46    #[error("IoError on `{0:?}`: {1}")]
47    IoPathError(PathBuf, #[source] IoError),
48    #[error("Invalid semver")]
49    InvalidSemver,
50    #[error("Command `{}` had a non-zero exit code.", format!("{:?}", .0).replace('"', ""))]
51    CmdFailed(Box<Command>),
52    #[error(transparent)]
53    Serialize(#[from] quick_xml::SeError),
54    #[error("String `{1}` is not a UID")]
55    NotAUid(#[source] ParseIntError, String),
56    #[error("Could not find `package:{package}` in output `{output}`")]
57    PackageNotInOutput { package: String, output: String },
58    #[error("Could not find `uid:` in output `{0}`")]
59    UidNotInOutput(String),
60    #[error(transparent)]
61    Utf8(#[from] Utf8Error),
62    #[error(transparent)]
63    ParseInt(#[from] ParseIntError),
64}