Skip to content
Snippets Groups Projects
Commit a46234b7 authored by Marco Biasini's avatar Marco Biasini
Browse files

issue better error when PDBWriter can't create the file

parent 5408de0e
No related branches found
No related tags found
No related merge requests found
......@@ -339,13 +339,14 @@ PDBWriter::PDBWriter(const boost::filesystem::path& filename,
#endif
mol_count_(0), line_(80), multi_model_(false),
charmm_style_(profile.dialect=="CHARMM"), is_pqr_(false),
profile_(profile)
{}
profile_(profile), filename_("")
{
}
PDBWriter::PDBWriter(const String& filename, const IOProfile& profile):
outfile_(filename.c_str()), outstream_(outfile_), mol_count_(0), line_(80),
multi_model_(false), charmm_style_(profile.dialect=="CHARMM"),
is_pqr_(false), profile_(profile)
is_pqr_(false), profile_(profile), filename_(filename)
{}
void PDBWriter::WriteModelLeader()
......@@ -368,6 +369,14 @@ void PDBWriter::WriteModelTrailer()
template <typename H>
void PDBWriter::WriteModel(H ent)
{
if (!outstream_) {
if (!filename_.empty()) {
std::stringstream ss;
ss << "Can't write PDB to file '" << filename_ << "'";
throw IOException(ss.str());
}
throw IOException("Can't write PDB. Bad stream");
}
ForcePOSIX posix;
this->WriteModelLeader();
PDBWriterImpl writer(outstream_,line_, atom_indices_, charmm_style_);
......
......@@ -75,6 +75,7 @@ private:
bool charmm_style_;
bool is_pqr_;
IOProfile profile_;
String filename_;
};
}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment