From ba7d6a842cb4d61357b588fb2d3ec552c654ae64 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 8 Jan 2019 23:18:32 -0800 Subject: huge refactor of rust modules/files Taking advantage of new Rust 2018 crate/module path changes, and re-organizing things. Somewhat optimistic this could help with partial rebuild speed also. --- rust/src/errors.rs | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 rust/src/errors.rs (limited to 'rust/src/errors.rs') diff --git a/rust/src/errors.rs b/rust/src/errors.rs new file mode 100644 index 00000000..0b966e93 --- /dev/null +++ b/rust/src/errors.rs @@ -0,0 +1,55 @@ +//! Crate-specific Result, Error, and ErrorKind types (using `error_chain`) + +error_chain! { + foreign_links { Fmt(::std::fmt::Error); + Diesel(::diesel::result::Error); + R2d2(::diesel::r2d2::Error); + Uuid(::uuid::ParseError); + Io(::std::io::Error) #[cfg(unix)]; + Serde(::serde_json::Error); + Utf8Decode(::std::string::FromUtf8Error); + StringDecode(::data_encoding::DecodeError); + } + errors { + InvalidFatcatId(id: String) { + description("invalid fatcat identifier syntax") + display("invalid fatcat identifier (expect 26-char base32 encoded): {}", id) + } + MalformedExternalId(id: String) { + description("external identifier doesn't match required pattern") + display("external identifier doesn't match required pattern: {}", id) + } + MalformedChecksum(hash: String) { + description("checksum doesn't match required pattern (hex encoding)") + display("checksum doesn't match required pattern (hex encoding): {}", hash) + } + NotInControlledVocabulary(word: String) { + description("word or type not correct for controlled vocabulary") + display("word or type not correct for controlled vocabulary") + } + EditgroupAlreadyAccepted(id: String) { + description("editgroup was already accepted") + display("attempted to accept or mutate an editgroup which was already accepted: {}", id) + } + MissingOrMultipleExternalId(message: String) { + description("external identifiers missing or multiple specified") + display("external identifiers missing or multiple specified; please supply exactly one") + } + InvalidEntityStateTransform(message: String) { + description("Invalid Entity State Transform") + display("tried to mutate an entity which was not in an appropriate state: {}", message) + } + InvalidCredentials(message: String) { + description("auth token was missing, expired, revoked, or corrupt") + display("auth token was missing, expired, revoked, or corrupt: {}", message) + } + InsufficientPrivileges(message: String) { + description("editor account doesn't have authorization") + display("editor account doesn't have authorization: {}", message) + } + OtherBadRequest(message: String) { + description("catch-all error for bad or unallowed requests") + display("broke a constraint or made an otherwise invalid request: {}", message) + } + } +} -- cgit v1.2.3