Skip to content
Snippets Groups Projects
Commit 7bda4fa3 authored by andreas's avatar andreas
Browse files

added more meaningfull error messages in info Import

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2702 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 63b1fe78
No related branches found
No related tags found
No related merge requests found
...@@ -97,12 +97,7 @@ InfoImpl::InfoImpl(const String& fname): ...@@ -97,12 +97,7 @@ InfoImpl::InfoImpl(const String& fname):
document_("EMDataInfo"), document_("EMDataInfo"),
def_list_() def_list_()
{ {
QFile file(QS(fname)); Import(fname);
if (!document_.setContent(&file)) {
file.close();
throw(InfoError("QDomDocument.setContent failed"));
}
file.close();
} }
RootPtr InfoImpl::Copy() const RootPtr InfoImpl::Copy() const
...@@ -117,9 +112,34 @@ void InfoImpl::Import(const String& fname) ...@@ -117,9 +112,34 @@ void InfoImpl::Import(const String& fname)
{ {
document_=QDomDocument("EMDataInfo"); document_=QDomDocument("EMDataInfo");
QFile file(QS(fname)); QFile file(QS(fname));
if (!document_.setContent(&file)) { if(!file.exists()){
file.close(); file.close();
throw(InfoError("QDomDocument.setContent failed")); throw(InfoError("File: "+fname+" doesn't exist."));
}
QString errormessage;
int errorline,errorcolumn;
if (!document_.setContent(&file,&errormessage,&errorline,&errorcolumn)) {
file.close();
if(file.error()){
switch(file.error()){
case QFile::ReadError:
throw(InfoError("Error while reading file: "+fname));
break;
case QFile::OpenError:
throw(InfoError("File: "+fname+" could not be opened."));
break;
case QFile::PermissionsError:
throw(InfoError("Permission error accessing file: "+fname));
break;
default:
throw(InfoError("Unspecified error while accessing file: "+fname));
break;
}
}else{
std::ostringstream stream;
stream << "Error while accessing file " << fname << ": " << errormessage.toStdString() << " in line " << errorline << " column " << errorcolumn;
throw(InfoError(stream.str()));
}
} }
file.close(); file.close();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment