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

6
Cargo.lock generated
View File

@ -1473,12 +1473,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "protobuf"
version = "3.0.0-pre"
source = "git+https://github.com/stepancheg/rust-protobuf#4c97ba2a1624626d2ac8472ec9139613744f1de9"
source = "git+https://github.com/stepancheg/rust-protobuf#c28865f0ada87733b80806eecbdcbd4906d13ee3"
[[package]]
name = "protobuf-codegen"
version = "3.0.0-pre"
source = "git+https://github.com/stepancheg/rust-protobuf#4c97ba2a1624626d2ac8472ec9139613744f1de9"
source = "git+https://github.com/stepancheg/rust-protobuf#c28865f0ada87733b80806eecbdcbd4906d13ee3"
dependencies = [
"protobuf 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
]
@ -1486,7 +1486,7 @@ dependencies = [
[[package]]
name = "protobuf-codegen-pure"
version = "3.0.0-pre"
source = "git+https://github.com/stepancheg/rust-protobuf#4c97ba2a1624626d2ac8472ec9139613744f1de9"
source = "git+https://github.com/stepancheg/rust-protobuf#c28865f0ada87733b80806eecbdcbd4906d13ee3"
dependencies = [
"protobuf 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",
"protobuf-codegen 3.0.0-pre (git+https://github.com/stepancheg/rust-protobuf)",

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),