Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/ghostscript4js.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ void GhostscriptManager::Init()
code = gsapi_new_instance(&minst, NULL);
if (code < 0)
{
throw "Sorry error happened creating Ghostscript instance. Error code: " + to_string(code);
throw std::runtime_error("Sorry error happened creating Ghostscript instance. Error code: " + to_string(code));
}
gsapi_set_stdio(minst, gsdll_stdin, gsdll_stdout, gsdll_stderr);
code = gsapi_set_arg_encoding(minst, GS_ARG_ENCODING_UTF8);
if (code < 0)
{
throw "Sorry error happened in setting the encoding for Ghostscript interpreter. Error code: " + to_string(code);
throw std::runtime_error("Sorry error happened in setting the encoding for Ghostscript interpreter. Error code: " + to_string(code));
}
}

Expand All @@ -99,7 +99,7 @@ void GhostscriptManager::Execute(int gsargc, char *gsargv[])
code = gsapi_init_with_args(minst, gsargc, gsargv);
if (code < 0 && code != gs_error_Quit)
{
throw "Sorry error happened executing Ghostscript command. Error code: " + to_string(code);
throw std::runtime_error("Sorry error happened executing Ghostscript command. Error code: " + to_string(code));
}
DecreaseWorkers();
if (workers == 0)
Expand All @@ -118,7 +118,7 @@ void GhostscriptManager::Exit()
code = gsapi_exit(minst);
if (code < 0 && code != gs_error_Quit)
{
throw "Sorry error happened during the exit from the Ghostscript interpreter. Error code: " + to_string(code);
throw std::runtime_error("Sorry error happened during the exit from the Ghostscript interpreter. Error code: " + to_string(code));
}
}

Expand Down Expand Up @@ -162,12 +162,11 @@ class GhostscriptWorker : public Napi::AsyncWorker
GhostscriptManager *gm = GhostscriptManager::GetInstance();
gm->Execute(gsargc, gsargv);
delete[] gsargv;

}
catch (exception &e)
{
delete[] gsargv;
SetError(Napi::String::New(Env(), e.what()));
SetError(e.what());
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/ghostscript4js.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ describe('Test ghostscript4js', function () {
expect(gs.version).not.toThrow()
const version = gs.version()
expect(version.product).toContain('GPL Ghostscript')
expect(version.copyright).toContain('Copyright (C) 2017 Artifex Software, Inc. All rights reserved.')
expect(version.copyright).toContain('Copyright (C)')
expect(version.copyright).toContain('Artifex Software, Inc. All rights reserved.')
expect(version.product).not.toBeLessThan(gs.MIN_SUPPORTED_REVISION)
expect(version.product).not.toBeLessThan(20160323)
})
Expand Down