forked from emk/subtitles-rs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
errors.rs
35 lines (29 loc) · 771 Bytes
/
errors.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! Error-handling for this library.
// `error-chain` makes it hard to document all the definitions it
// generates.
#![allow(missing_docs)]
use csv;
use handlebars;
use rustc_serialize::json;
use std::io;
use std::str;
use uchardet;
use grammar;
error_chain! {
links {
Uchardet(uchardet::Error, uchardet::ErrorKind);
}
foreign_links {
Csv(csv::Error);
Io(io::Error);
JsonDecoder(json::DecoderError);
Parse(grammar::ParseError);
Render(handlebars::RenderError);
Template(handlebars::TemplateError);
Utf8(str::Utf8Error);
}
}
/// Create a new error from something that can be turned into a string.
pub fn err_str<T: Into<String>>(message: T) -> Error {
From::from(message.into())
}