improve error messages on unparseable text protos

Takes advantage of stepancheg/rust-protobuf#428
This commit is contained in:
Scott Lamb
2019-07-20 16:22:24 -07:00
parent 79ac89dc7c
commit 01d20960ef
3 changed files with 7 additions and 7 deletions

View File

@@ -32,7 +32,7 @@
use base::clock::{self, Clocks};
use db::auth::SessionFlags;
use failure::{Error, bail, format_err};
use failure::{Error, ResultExt, bail, format_err};
use serde::Deserialize;
use std::os::unix::fs::OpenOptionsExt as _;
use std::io::Write as _;
@@ -89,7 +89,7 @@ pub fn run() -> Result<(), Error> {
let permissions = match args.flag_permissions {
None => u.permissions.clone(),
Some(s) => protobuf::text_format::parse_from_str(&s)
.map_err(|_| format_err!("unable to parse --permissions"))?
.context("unable to parse --permissions")?
};
let creation = db::auth::Request {
when_sec: Some(db.clocks().realtime().sec),

View File

@@ -33,7 +33,7 @@ use crate::stream;
use crate::streamer;
use crate::web;
use db::{dir, writer};
use failure::{Error, bail, format_err};
use failure::{Error, ResultExt, bail};
use fnv::FnvHashMap;
use futures::{Future, Stream};
use log::{error, info, warn};
@@ -195,7 +195,7 @@ pub fn run() -> Result<(), Error> {
let allow_unauthenticated_permissions = args.flag_allow_unauthenticated_permissions
.map(|s| protobuf::text_format::parse_from_str(&s))
.transpose()
.map_err(|_| format_err!("Unable to parse --allow-unauthenticated-permissions"))?;
.context("Unable to parse --allow-unauthenticated-permissions")?;
let s = web::Service::new(web::Config {
db: db.clone(),
ui_dir: Some(&args.flag_ui_dir),