devtools: handle script task panics gracefully in ConsoleActor.

This commit is contained in:
Eduard Burtescu 2014-12-05 02:57:32 +02:00
parent 92a8c7a80c
commit b328c57caa
6 changed files with 44 additions and 31 deletions

View file

@ -118,8 +118,8 @@ impl Actor for ConsoleActor {
_registry: &ActorRegistry,
msg_type: &String,
msg: &json::JsonObject,
stream: &mut TcpStream) -> bool {
match msg_type.as_slice() {
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"getCachedMessages" => {
let types = msg.get(&"messageTypes".to_string()).unwrap().as_list().unwrap();
let /*mut*/ messages = vec!();
@ -223,7 +223,7 @@ impl Actor for ConsoleActor {
self.script_chan.send(EvaluateJS(self.pipeline, input.clone(), chan));
//TODO: extract conversion into protocol module or some other useful place
let result = match port.recv() {
let result = match try!(port.recv_opt()) {
VoidValue => {
let mut m = TreeMap::new();
m.insert("type".to_string(), "undefined".to_string().to_json());
@ -285,6 +285,6 @@ impl Actor for ConsoleActor {
}
_ => false
}
})
}
}