@@ -6,13 +6,14 @@ extern crate irc;
6
6
extern crate toml;
7
7
extern crate hyper;
8
8
extern crate url;
9
- extern crate serde_json as json ;
9
+ extern crate rustc_serialize ;
10
10
11
11
use rust_playpen:: ReleaseChannel ;
12
12
13
13
use irc:: client:: prelude:: * ;
14
14
use url:: form_urlencoded;
15
15
use hyper:: client:: Client ;
16
+ use rustc_serialize:: json;
16
17
17
18
use std:: fs:: { self , File } ;
18
19
use std:: io:: { self , Read } ;
@@ -74,10 +75,10 @@ impl Playbot {
74
75
let mut response = try!( client. get ( & url) . send ( ) ) ;
75
76
let mut body = String :: new ( ) ;
76
77
try!( response. read_to_string ( & mut body) ) ;
77
- let value: json:: Value = json:: from_str ( & body) . unwrap ( ) ;
78
+ let value: json:: Json = json:: Json :: from_str ( & body) . unwrap ( ) ;
78
79
let obj = value. as_object ( ) . unwrap ( ) ;
79
80
if obj[ "status_txt" ] . as_string ( ) . unwrap ( ) == "OK" {
80
- Ok ( String :: from ( value. lookup ( "data. url" ) . unwrap ( ) . as_string ( ) . unwrap ( ) ) )
81
+ Ok ( String :: from ( value. find_path ( & [ "data" , " url"] ) . unwrap ( ) . as_string ( ) . unwrap ( ) ) )
81
82
} else {
82
83
Err ( io:: Error :: new ( io:: ErrorKind :: Other ,
83
84
format ! ( "server responded with: {}" , body) ) . into ( ) )
@@ -139,7 +140,7 @@ fn main() {{
139
140
Ok ( short_url) => response. push_str ( & format ! ( "\n (output truncated; full output at {})" ,
140
141
short_url) ) ,
141
142
Err ( e) => {
142
- log_error ( e) ;
143
+ error ! ( "shortening url failed: {}" , e) ;
143
144
response. push_str ( "\n (output truncated; shortening URL failed)" ) ;
144
145
}
145
146
}
@@ -153,13 +154,13 @@ fn main() {{
153
154
for line in response. lines ( ) {
154
155
if !line. is_empty ( ) {
155
156
if let Err ( e) = self . conn . send_notice ( response_to, line) {
156
- log_error ( e) ;
157
+ error ! ( "couldn't send response: {}" , e) ;
157
158
}
158
159
}
159
160
}
160
161
}
161
162
Err ( e) => {
162
- log_error ( e) ;
163
+ error ! ( "{}" , e) ;
163
164
}
164
165
}
165
166
}
@@ -214,11 +215,6 @@ fn main() {{
214
215
}
215
216
}
216
217
217
- /// Log and forget an error
218
- fn log_error < E : Error > ( e : E ) {
219
- println ! ( "[ERROR] {}" , e) ;
220
- }
221
-
222
218
fn main ( ) {
223
219
env_logger:: init ( ) . unwrap ( ) ;
224
220
0 commit comments