using namespace etl;
using namespace std;
-namespace synfig { extern Canvas::Handle open_canvas(const String &filename); };
+namespace synfig { extern Canvas::Handle open_canvas(const String &filename, String &errors); };
/* === M A C R O S ========================================================= */
external_canvas=externals_[file_name];
else
{
+ String errors;
if(is_absolute_path(file_name))
- external_canvas=open_canvas(file_name);
+ external_canvas=open_canvas(file_name, errors);
else
- external_canvas=open_canvas(get_file_path()+ETL_DIRECTORY_SEPARATOR+file_name);
+ external_canvas=open_canvas(get_file_path()+ETL_DIRECTORY_SEPARATOR+file_name, errors);
if(!external_canvas)
throw Exception::FileNotFound(file_name);
external_canvas=externals_[file_name];
else
{
+ String errors;
if(is_absolute_path(file_name))
- external_canvas=open_canvas(file_name);
+ external_canvas=open_canvas(file_name, errors);
else
- external_canvas=open_canvas(get_file_path()+ETL_DIRECTORY_SEPARATOR+file_name);
+ external_canvas=open_canvas(get_file_path()+ETL_DIRECTORY_SEPARATOR+file_name, errors);
if(!external_canvas)
throw Exception::FileNotFound(file_name);
}
Canvas::Handle
-synfig::open_canvas(const String &filename)
+synfig::open_canvas(const String &filename,String &errors)
{
- CanvasParser parser;
-
- parser.set_allow_errors(true);
-
- Canvas::Handle canvas=parser.parse_from_file(filename);
-
- if(parser.error_count())
- return Canvas::Handle();
-
- return canvas;
+ return open_canvas_as(filename, filename, errors);
}
Canvas::Handle
-synfig::open_canvas_as(const String &filename,const String &as)
+synfig::open_canvas_as(const String &filename,const String &as,String &errors)
{
CanvasParser parser;
parser.set_allow_errors(true);
- Canvas::Handle canvas=parser.parse_from_file_as(filename,as);
+ Canvas::Handle canvas=parser.parse_from_file_as(filename,as,errors);
if(parser.error_count())
+ {
+ errors = parser.get_errors_text();
return Canvas::Handle();
+ }
return canvas;
}
{
string str=strprintf("%s:<%s>:%d: error: ",filename.c_str(),element->get_name().c_str(),element->get_line())+text;
total_errors_++;
+ errors_text += " " + str + "\n";
if(!allow_errors_)
throw runtime_error(str);
cerr<<str<<endl;
}
Canvas::Handle
-CanvasParser::parse_from_file(const String &file)
-{
- return parse_from_file_as(file,file);
-}
-
-Canvas::Handle
-CanvasParser::parse_from_file_as(const String &file_,const String &as_)
+CanvasParser::parse_from_file_as(const String &file_,const String &as_,String &errors)
{
try
{
catch(const std::exception& ex)
{
synfig::error("Standard Exception: "+String(ex.what()));
+ errors = ex.what();
return Canvas::Handle();
}
catch(const String& str)
{
cerr<<str<<endl;
// synfig::error(str);
+ errors = str;
return Canvas::Handle();
}
return Canvas::Handle();
String path;
+ String errors_text;
+
GUID guid_;
/*
const synfig::String& get_path()const { return path; }
- //! \todo writeme
- Canvas::Handle parse_from_file(const String &filename);
+ const synfig::String& get_errors_text()const { return errors_text; }
- Canvas::Handle parse_from_file_as(const String &filename,const String &as);
+ //! \todo writeme
+ Canvas::Handle parse_from_file_as(const String &filename,const String &as,String &errors);
//! \todo writeme
Canvas::Handle parse_from_string(const String &data);
//! Loads a canvas from \a filename
/*! \return The Canvas's handle on success, an empty handle on failure */
-extern Canvas::Handle open_canvas(const String &filename);
-extern Canvas::Handle open_canvas_as(const String &filename,const String &as);
+extern Canvas::Handle open_canvas(const String &filename,String &errors);
+extern Canvas::Handle open_canvas_as(const String &filename,const String &as,String &errors);
//! Retrieves a Canvas from a string in XML format
extern Canvas::Handle string_to_canvas(const String &data);
return ret;
// Open the composition
- job_list.front().root=open_canvas(job_list.front().filename);
+ String errors;
+ job_list.front().root=open_canvas(job_list.front().filename, errors);
if(!job_list.front().root)
{
extract_append(imageargs,composite_file);
if(!composite_file.empty())
{
- Canvas::Handle composite(open_canvas(composite_file));
+ String errors;
+ Canvas::Handle composite(open_canvas(composite_file, errors));
if(!composite)
break;
Canvas::reverse_iterator iter;
try
{
OneMoment one_moment;
+ String errors;
- etl::handle<synfig::Canvas> canvas(open_canvas_as(filename,as));
+ etl::handle<synfig::Canvas> canvas(open_canvas_as(filename,as,errors));
if(canvas && get_instance(canvas))
{
get_instance(canvas)->find_canvas_view(canvas)->present();
else
{
if(!canvas)
- throw (String)strprintf(_("Unable to open file \"%s\""),filename.c_str());
+ throw (String)strprintf(_("Unable to open file \"%s\":\n\n"),filename.c_str()) + errors;
if (as.find(custom_filename_prefix.c_str()) != 0)
add_recent_file(as);
// If this is a SIF file, then we need to do things slightly differently
if(ext=="sif" || ext=="sifz")try
{
-
- Canvas::Handle outside_canvas(synfig::open_canvas(filename));
+ String errors;
+ Canvas::Handle outside_canvas(synfig::open_canvas(filename, errors));
if(!outside_canvas)
throw String(_("Unable to open this composition"));