From 0525f998c88bafb94625d4e08dd1cedbb87c8a02 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 27 Feb 2017 14:55:16 +0100 Subject: [PATCH] Fix usage of StoreId::exists() -> raise Error if error occurs --- libimagruby/src/storeid.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libimagruby/src/storeid.rs b/libimagruby/src/storeid.rs index a8200649..ce3f50a7 100644 --- a/libimagruby/src/storeid.rs +++ b/libimagruby/src/storeid.rs @@ -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 {