88
99#[ cfg( feature = "remote-run" ) ]
1010use czmq;
11+ use regex;
1112use rustc_serialize:: json;
1213use std:: { convert, error, fmt, io, num, str, string} ;
1314#[ cfg( feature = "remote-run" ) ]
@@ -18,6 +19,9 @@ pub enum Error {
1819 /// An error string returned from the host's Intecture Agent
1920 Agent ( String ) ,
2021 #[ cfg( feature = "remote-run" ) ]
22+ /// An error string returned from the host's Intecture Auth
23+ Auth ( String ) ,
24+ #[ cfg( feature = "remote-run" ) ]
2125 /// CZMQ error
2226 Czmq ( czmq:: Error ) ,
2327 /// JSON decoder error
@@ -39,6 +43,8 @@ pub enum Error {
3943 ParseFloat ( num:: ParseFloatError ) ,
4044 /// Cast str as int
4145 ParseInt ( num:: ParseIntError ) ,
46+ /// Regex error
47+ Regex ( regex:: Error ) ,
4248 /// Cast str
4349 StrFromUtf8 ( str:: Utf8Error ) ,
4450 /// Cast String
@@ -53,6 +59,8 @@ impl fmt::Display for Error {
5359 match * self {
5460 Error :: Agent ( ref e) => write ! ( f, "Agent error: {}" , e) ,
5561 #[ cfg( feature = "remote-run" ) ]
62+ Error :: Auth ( ref e) => write ! ( f, "Auth error: {}" , e) ,
63+ #[ cfg( feature = "remote-run" ) ]
5664 Error :: Czmq ( ref e) => write ! ( f, "CZMQ error: {}" , e) ,
5765 Error :: JsonDecoder ( ref e) => write ! ( f, "JSON decoder error: {}" , e) ,
5866 #[ cfg( feature = "remote-run" ) ]
@@ -65,6 +73,7 @@ impl fmt::Display for Error {
6573 Error :: Io ( ref e) => write ! ( f, "IO error: {}" , e) ,
6674 Error :: ParseFloat ( ref e) => write ! ( f, "Parse error: {}" , e) ,
6775 Error :: ParseInt ( ref e) => write ! ( f, "Parse error: {}" , e) ,
76+ Error :: Regex ( ref e) => write ! ( f, "Regex error: {}" , e) ,
6877 Error :: StrFromUtf8 ( ref e) => write ! ( f, "Convert from UTF8 slice to str error: {}" , e) ,
6978 Error :: StringFromUtf8 ( ref e) => write ! ( f, "Convert from UTF8 slice to String error: {}" , e) ,
7079 #[ cfg( feature = "remote-run" ) ]
@@ -78,6 +87,8 @@ impl error::Error for Error {
7887 match * self {
7988 Error :: Agent ( ref e) => e,
8089 #[ cfg( feature = "remote-run" ) ]
90+ Error :: Auth ( ref e) => e,
91+ #[ cfg( feature = "remote-run" ) ]
8192 Error :: Czmq ( ref e) => e. description ( ) ,
8293 Error :: JsonDecoder ( ref e) => e. description ( ) ,
8394 #[ cfg( feature = "remote-run" ) ]
@@ -90,6 +101,7 @@ impl error::Error for Error {
90101 Error :: Io ( ref e) => e. description ( ) ,
91102 Error :: ParseFloat ( ref e) => e. description ( ) ,
92103 Error :: ParseInt ( ref e) => e. description ( ) ,
104+ Error :: Regex ( ref e) => e. description ( ) ,
93105 Error :: StrFromUtf8 ( ref e) => e. description ( ) ,
94106 Error :: StringFromUtf8 ( ref e) => e. description ( ) ,
95107 #[ cfg( feature = "remote-run" ) ]
@@ -124,6 +136,12 @@ impl convert::From<io::Error> for Error {
124136 }
125137}
126138
139+ impl convert:: From < regex:: Error > for Error {
140+ fn from ( err : regex:: Error ) -> Error {
141+ Error :: Regex ( err)
142+ }
143+ }
144+
127145impl convert:: From < str:: Utf8Error > for Error {
128146 fn from ( err : str:: Utf8Error ) -> Error {
129147 Error :: StrFromUtf8 ( err)
0 commit comments