From e0e66e616dfcc17303200095540fe76fc27de036 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 1 Jun 2024 23:32:24 +0200 Subject: [PATCH] improve error handling --- Cargo.lock | 21 +++++++++++++++++++++ libcsp-cargo-build/Cargo.toml | 1 + libcsp-cargo-build/src/lib.rs | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 5e29b4e..e53e5c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,6 +57,7 @@ name = "libcsp-cargo-build" version = "0.2.0" dependencies = [ "cc", + "thiserror", ] [[package]] @@ -139,6 +140,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "toml_datetime" version = "0.6.6" diff --git a/libcsp-cargo-build/Cargo.toml b/libcsp-cargo-build/Cargo.toml index 5a990ae..fb802dc 100644 --- a/libcsp-cargo-build/Cargo.toml +++ b/libcsp-cargo-build/Cargo.toml @@ -12,3 +12,4 @@ categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support" [dependencies] cc = "1" +thiserror = "1" diff --git a/libcsp-cargo-build/src/lib.rs b/libcsp-cargo-build/src/lib.rs index 6b57e16..16a5b27 100644 --- a/libcsp-cargo-build/src/lib.rs +++ b/libcsp-cargo-build/src/lib.rs @@ -133,9 +133,11 @@ pub struct Builder { build: cc::Build, } -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, thiserror::Error)] pub enum BuildCreationError { + #[error("The specified libcsp path does not exist")] PathDoesNotExist, + #[error("The specified libcsp path does not have the expected format of the library")] InvalidLibcspFormat, }