summaryrefslogtreecommitdiffstats
path: root/rust/src/api_server.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-06-20 09:38:03 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-06-20 09:38:03 -0700
commit381fe70c56b1a936d4eef676ee8ba546f6a3cf30 (patch)
tree5447e70f214c42b0ca3a533f64e828ff9410587f /rust/src/api_server.rs
parentbde5c8f14e13afe4d54e9bfafd8bda8b0f33f804 (diff)
downloadfatcat-381fe70c56b1a936d4eef676ee8ba546f6a3cf30.tar.gz
fatcat-381fe70c56b1a936d4eef676ee8ba546f6a3cf30.zip
handle UUID errors as HTTP 400
Diffstat (limited to 'rust/src/api_server.rs')
-rw-r--r--rust/src/api_server.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 24c62625..4c0f069e 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -57,6 +57,8 @@ macro_rules! wrap_entity_handlers {
$post_resp::CreatedEntity(edit),
Err(Error(ErrorKind::Diesel(e), _)) =>
$post_resp::BadRequest(ErrorResponse { message: e.to_string() }),
+ Err(Error(ErrorKind::Uuid(e), _)) =>
+ $post_resp::BadRequest(ErrorResponse { message: e.to_string() }),
Err(e) => $post_resp::GenericError(ErrorResponse { message: e.to_string() }),
};
Box::new(futures::done(Ok(ret)))
@@ -72,6 +74,8 @@ macro_rules! wrap_entity_handlers {
$post_batch_resp::CreatedEntities(edit),
Err(Error(ErrorKind::Diesel(e), _)) =>
$post_batch_resp::BadRequest(ErrorResponse { message: e.to_string() }),
+ Err(Error(ErrorKind::Uuid(e), _)) =>
+ $post_batch_resp::BadRequest(ErrorResponse { message: e.to_string() }),
Err(e) => $post_batch_resp::GenericError(ErrorResponse { message: e.to_string() }),
};
Box::new(futures::done(Ok(ret)))
@@ -661,9 +665,9 @@ impl Server {
Some(param) => param as i64,
};
- let work_id = uuid::Uuid::parse_str(&entity.work_id).expect("invalid UUID");
+ let work_id = uuid::Uuid::parse_str(&entity.work_id)?;
let container_id: Option<uuid::Uuid> = match entity.container_id {
- Some(id) => Some(uuid::Uuid::parse_str(&id).expect("invalid UUID")),
+ Some(id) => Some(uuid::Uuid::parse_str(&id)?),
None => None,
};