Fix usage of StoreId::exists() -> raise Error if error occurs

This commit is contained in:
Matthias Beyer 2017-02-27 14:55:16 +01:00
parent c2838cca3b
commit 0525f998c8

View file

@ -19,7 +19,7 @@
use std::path::PathBuf;
use ruru::{Class, Object, AnyObject, Boolean, RString, NilClass, VerifiedObject};
use ruru::{Class, Object, AnyObject, Boolean, RString, NilClass, VerifiedObject, VM};
use libimagstore::storeid::StoreId;
use util::Unwrap;
@ -116,7 +116,15 @@ methods!(
}
fn r_storeid_exists() -> Boolean {
Boolean::new(itself.get_data(&*STOREID_WRAPPER).exists())
use std::error::Error;
match itself.get_data(&*STOREID_WRAPPER).exists() {
Ok(bool) => Boolean::new(bool),
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
Boolean::new(false)
}
}
}
fn r_storeid_to_str() -> AnyObject {