diff --git a/ext/phashion_ext/phashion_ext.c b/ext/phashion_ext/phashion_ext.c index e2b79cb..6232c25 100644 --- a/ext/phashion_ext/phashion_ext.c +++ b/ext/phashion_ext/phashion_ext.c @@ -83,11 +83,16 @@ static VALUE mh_hash_for(VALUE self, VALUE filename, VALUE alpha, VALUE lvl) { uint8_t* result; int n; VALUE array; - result = ph_mh_imagehash(StringValuePtr(filename), - n, - NUM2DBL(alpha), - NUM2DBL(lvl)); - array = rb_ary_new2(n); + + try { + result = ph_mh_imagehash(StringValuePtr(filename), + n, + NUM2DBL(alpha), + NUM2DBL(lvl)); + array = rb_ary_new2(n); + } catch (exception e) { + rb_raise(rb_eRuntimeError, "Unknown pHash error"); + } for(int i = 0; i < n; i++) { rb_ary_push(array, INT2FIX(result[i]));