Replace uses of RuntimeError with own error types

This commit is contained in:
Matthias Beyer 2017-03-07 17:47:56 +01:00
parent 2f745193bf
commit a14d10fd47
2 changed files with 26 additions and 26 deletions

View File

@ -79,11 +79,11 @@ macro_rules! call_on_fle_from_store {
$operation
},
Ok(None) => {
VM::raise(Class::from_existing("RuntimeError"), "Obj does not exist");
VM::raise(Class::from_existing("RImagStoreReadError"), "Obj does not exist");
NilClass::new().to_any_object()
},
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreReadError"), e.description());
NilClass::new().to_any_object()
},
}
@ -100,11 +100,11 @@ macro_rules! call_on_fle_from_store {
$operation
},
Ok(None) => {
VM::raise(Class::from_existing("RuntimeError"), "Obj does not exist");
VM::raise(Class::from_existing("RImagStoreReadError"), "Obj does not exist");
$ex
},
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreReadError"), e.description());
$ex
},
}
@ -133,7 +133,7 @@ methods!(
let entryheader = match typecheck!(hdr or return NilClass::new()).into_toml() {
Value::Table(t) => Value::Table(t),
_ => {
let ec = Class::from_existing("RuntimeError");
let ec = Class::from_existing("RImagEntryHeaderWriteError");
VM::raise(ec, "Something weird happened. Hash seems to be not a Hash");
return NilClass::new();
},
@ -160,7 +160,7 @@ methods!(
let content = match typecheck!(ctt).into_toml() {
Value::String(s) => s,
_ => {
let ec = Class::from_existing("RuntimeError");
let ec = Class::from_existing("RImagEntryError");
VM::raise(ec, "Something weird happened. String seems to be not a String");
return NilClass::new();
},
@ -197,7 +197,7 @@ methods!(
match itself.get_data(&*ENTRY_HEADER_WRAPPER).insert(&spec, obj.into_toml()) {
Ok(b) => Boolean::new(b),
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagEntryHeaderWriteError"), e.description());
Boolean::new(false)
}
}
@ -213,7 +213,7 @@ methods!(
Ok(Some(v)) => v.into_ruby(),
Ok(None) => NilClass::new().to_any_object(),
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagEntryHeaderWriteError"), e.description());
return Boolean::new(false).to_any_object();
}
}
@ -228,7 +228,7 @@ methods!(
Ok(Some(v)) => v.into_ruby(),
Ok(None) => NilClass::new().to_any_object(),
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagEntryHeaderReadError"), e.description());
return Boolean::new(false).to_any_object();
}
}

View File

@ -61,14 +61,14 @@ macro_rules! call_on_store_by_handle {
match hm.get($store_handle) {
Some($name) => { $operation },
None => {
VM::raise(Class::from_existing("RuntimeError"),
VM::raise(Class::from_existing("RImagStoreReadError"),
"Tried to operate on non-existing object");
$ex
}
}
},
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagError"), e.description());
$ex
}
}
@ -102,11 +102,11 @@ macro_rules! call_on_store {
let $fle_name = match $store_name.get($fle_handle_name) {
Ok(Some(fle)) => fle,
Ok(None) => {
VM::raise(Class::from_existing("RuntimeError"), "Obj does not exist");
VM::raise(Class::from_existing("RImagStoreReadError"), "Obj does not exist");
return $fail_expr
},
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreReadError"), e.description());
return $fail_expr
},
};
@ -174,14 +174,14 @@ methods!(
let rtp = PathBuf::from(typecheck!(rtp or return any NilClass::new()).to_string());
if !rtp.exists() || !rtp.is_dir() {
VM::raise(Class::from_existing("RuntimeError"), "Runtimepath not a directory");
VM::raise(Class::from_existing("RImagError"), "Runtimepath not a directory");
return NilClass::new().to_any_object();
}
let store_config = match Configuration::new(&rtp) {
Ok(mut cfg) => cfg.store_config().cloned(),
Err(e) => if e.err_type() != ConfigErrorKind::NoConfigFileFound {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagError"), e.description());
return NilClass::new().to_any_object();
} else {
warn!("No config file found.");
@ -248,7 +248,7 @@ methods!(
let store = match store {
Ok(s) => s,
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreError"), e.description());
return NilClass::new().to_any_object();
},
};
@ -264,7 +264,7 @@ methods!(
return store_handle.wrap().to_any_object();
},
Err(e) => {
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagError"), e.description());
return NilClass::new().to_any_object();
}
}
@ -291,7 +291,7 @@ methods!(
match store.create(sid.clone()) {
Err(e) => {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
NilClass::new().to_any_object()
},
Ok(entry) => {
@ -325,7 +325,7 @@ methods!(
match store.retrieve(sid.clone()) {
Err(e) => {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
NilClass::new().to_any_object()
},
Ok(entry) => {
@ -360,7 +360,7 @@ methods!(
match store.get(sid.clone()) {
Err(e) => {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
NilClass::new().to_any_object()
},
Ok(None) => NilClass::new().to_any_object(),
@ -397,7 +397,7 @@ methods!(
match store.retrieve_for_module(&name) {
Err(e) => {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
NilClass::new().to_any_object()
},
Ok(iter) => {
@ -428,7 +428,7 @@ methods!(
operation {
if let Err(e) = store.update(real_fle) {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
}
NilClass::new()
},
@ -451,7 +451,7 @@ methods!(
operation {
if let Err(e) = store.delete(sid) {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
}
NilClass::new()
},
@ -476,7 +476,7 @@ methods!(
operation {
if let Err(e) = store.save_to(&real_fle, sid) {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
}
NilClass::new()
},
@ -501,7 +501,7 @@ methods!(
operation {
if let Err(e) = store.save_as(real_fle, sid) {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
}
NilClass::new()
},
@ -525,7 +525,7 @@ methods!(
operation {
if let Err(e) = store.move_by_id(old, nw) {
trace_error(&e);
VM::raise(Class::from_existing("RuntimeError"), e.description());
VM::raise(Class::from_existing("RImagStoreWriteError"), e.description());
}
NilClass::new()
},