diff --git a/src/canvas.cc b/src/canvas.cc index b5f1c0b..bcc0cae 100644 --- a/src/canvas.cc +++ b/src/canvas.cc @@ -81,8 +81,11 @@ Canvas::StreamPNG(const Arguments &args) { Canvas *canvas = ObjectWrap::Unwrap(args.This()); closure_t closure; closure.fn = Handle::Cast(args[0]); + TryCatch try_catch; cairo_status_t status = cairo_surface_write_to_png_stream(canvas->getSurface(), writeToBuffer, &closure); - if (status) { + if (try_catch.HasCaught()) { + return try_catch.ReThrow(); + } else if (status) { Handle argv[1] = { Canvas::Error(status) }; closure.fn->Call(Context::GetCurrent()->Global(), 1, argv); } else {