From 300986fe58897667ba1c41859b5cec2f9e654efa Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 14 Oct 2017 20:05:57 +0200 Subject: Some basic error handling for SVG export --- src/main.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 5f6fc75cf..d934d1d77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1619,16 +1619,27 @@ static int do_export_svg(SPDocument* doc) } } + int ret = 0; if (sp_export_svg) { - Inkscape::Extension::save(Inkscape::Extension::db.get("org.inkscape.output.svg.plain"), doc, sp_export_svg, false, - false, false, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY); + try { + Inkscape::Extension::save(Inkscape::Extension::db.get("org.inkscape.output.svg.plain"), doc, sp_export_svg, false, + false, false, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY); + } catch (Inkscape::Extension::Output::save_failed &e) { + g_warning("Failed to save plain SVG to: %s", sp_export_svg); + ret = 1; + } } if (sp_export_inkscape_svg) { // Export as inkscape SVG. - Inkscape::Extension::save(Inkscape::Extension::db.get("org.inkscape.output.svg.inkscape"), doc, sp_export_inkscape_svg, false, - false, false, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG); + try { + Inkscape::Extension::save(Inkscape::Extension::db.get("org.inkscape.output.svg.inkscape"), doc, sp_export_inkscape_svg, false, + false, false, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG); + } catch (Inkscape::Extension::Output::save_failed &e) { + g_warning("Failed to save Inkscape SVG to: %s", sp_export_inkscape_svg); + ret = 1; + } } - return 0; + return ret; } /** -- cgit v1.2.3