Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the WrongModelVersion error message intelligible #133

Merged
merged 1 commit into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use failure::Fail;
pub enum SnipsNluError {
#[fail(display = "Unable to read file '{}'", _0)]
ModelLoad(String),
#[fail(display = "Expected model version {} but found {}", _1, _0)]
WrongModelVersion(String, &'static str),
#[fail(display = "Mismatched model version: model is {} but runner is {}", model, runner)]
WrongModelVersion{ model: String, runner: &'static str},
#[fail(display = "Unknown intent: '{}'", _0)]
UnknownIntent(String),
#[fail(display = "Internal error: {}", _0)]
Expand Down
8 changes: 4 additions & 4 deletions src/nlu_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ impl SnipsNluEngine {

let model_version: ModelVersion = serde_json::from_reader(model_file)?;
if model_version.model_version != crate::MODEL_VERSION {
bail!(SnipsNluError::WrongModelVersion(
model_version.model_version,
crate::MODEL_VERSION
));
bail!(SnipsNluError::WrongModelVersion {
model: model_version.model_version,
runner: crate::MODEL_VERSION
});
}
Ok(())
}
Expand Down