Skip to content

Commit

Permalink
added better error checking for shim compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
banister committed Jan 29, 2012
1 parent e3309bc commit 5f943bf
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions lib/pry-exception_explorer/shim_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
require 'fileutils'

module PryExceptionExplorer
CompileError = Class.new(StandardError)

module ShimBuilder
class << self
attr_reader :dir, :file
Expand All @@ -26,27 +28,15 @@ class << self
void
rb_raise(unsigned long exc, const char *fmt, ...)
{
static void (*libruby_rb_raise)
(unsigned long exc, const char *fmt, ...) = NULL;
void * handle;
char * error;
if (!libruby_rb_raise) {
handle = dlopen("#{RbConfig::CONFIG['libdir']}/libruby.#{Dyname}", RTLD_LAZY);
if (!handle) {
fputs(dlerror(), stderr);
exit(1);
}
libruby_rb_raise = dlsym(handle, "rb_raise");
if ((error = dlerror()) != NULL) {
fprintf(stderr, "%s", error);
exit(1);
}
}
rb_funcall(rb_cObject, rb_intern("raise"), 2, exc, rb_str_new2("hooked exception (pry)"));
}
void
rb_name_error(ID id, const char *fmt, ...)
{
rb_funcall(rb_cObject, rb_intern("raise"), 2, rb_eNameError, rb_str_new2("hooked exception (pry)"));
}
EOF

def self.create_directory_and_source_file
Expand Down Expand Up @@ -74,7 +64,9 @@ def self.compile
end

FileUtils.chdir @dir do
system(compile_line)
if !system(compile_line)
raise CompileError, "There was a problem building the shim, aborted!"
end
end

end
Expand Down

0 comments on commit 5f943bf

Please sign in to comment.