aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/errors.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-08 23:18:32 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-08 23:20:53 -0800
commitba7d6a842cb4d61357b588fb2d3ec552c654ae64 (patch)
tree41eb8c465cd1ad0a9f70e18f49905adf7e5c3b40 /rust/src/errors.rs
parenteb6fb8e5fe1efb3fbb927d13075cf5a1b33aa83e (diff)
downloadfatcat-ba7d6a842cb4d61357b588fb2d3ec552c654ae64.tar.gz
fatcat-ba7d6a842cb4d61357b588fb2d3ec552c654ae64.zip
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.
Diffstat (limited to 'rust/src/errors.rs')
-rw-r--r--rust/src/errors.rs55
1 files changed, 55 insertions, 0 deletions
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)
+ }
+ }
+}