#include "frontends/alert.h"
+#include "support/ExceptionMessage.h"
#include "support/debug.h"
#include "support/filetools.h"
#include "support/gettext.h"
using boost::bind;
using namespace std;
+using namespace lyx::support;
namespace lyx {
-using support::addName;
-using support::bformat;
-using support::FileName;
-using support::makeDisplayPath;
-using support::onlyFilename;
-using support::removeAutosaveFile;
-using support::package;
-using support::prefixIs;
-
namespace Alert = lyx::frontend::Alert;
Buffer * BufferList::newBuffer(string const & s, bool const ronly)
{
- auto_ptr<Buffer> tmpbuf(new Buffer(s, ronly));
+ auto_ptr<Buffer> tmpbuf;
+ try { tmpbuf.reset(new Buffer(s, ronly));
+ } catch (ExceptionMessage const & message) {
+ if (message.type_ == ErrorException) {
+ Alert::error(message.title_, message.details_);
+ exit(1);
+ } else if (message.type_ == WarningException) {
+ Alert::warning(message.title_, message.details_);
+ return 0;
+ }
+ }
tmpbuf->params().useClassDefaults();
LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size());
bstore.push_back(tmpbuf.get());
}
-int BufferList::bufferNum(std::string const & name) const
+int BufferList::bufferNum(string const & name) const
{
vector<string> buffers = getFileNames();
vector<string>::const_iterator cit =
- std::find(buffers.begin(), buffers.end(), name);
+ find(buffers.begin(), buffers.end(), name);
if (cit == buffers.end())
return 0;
return int(cit - buffers.begin());