#include "frontends/alert.h"
#include "frontends/alert.h"
+#include "support/ExceptionMessage.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
case LFUN_INSET_MODIFY: {
InsetCommandParams p("bibtex");
case LFUN_INSET_MODIFY: {
InsetCommandParams p("bibtex");
- InsetCommandMailer::string2params("bibtex", to_utf8(cmd.argument()), p);
- if (!p.getCmdName().empty()) {
- setParams(p);
- cur.buffer().updateBibfilesCache();
- } else
- cur.noUpdate();
+ try {
+ if (!InsetCommandMailer::string2params("bibtex",
+ to_utf8(cmd.argument()), p)) {
+ cur.noUpdate();
+ break;
+ }
+ } catch (support::ExceptionMessage const & message) {
+ if (message.type_ == support::WarningException) {
+ Alert::warning(message.title_, message.details_);
+ cur.noUpdate();
+ } else
+ throw message;
+ break;
+ }
+ setParams(p);
+ cur.buffer().updateBibfilesCache();
-void InsetCommandMailer::string2params(
+bool InsetCommandMailer::string2params(
string const & name, string const & in, InsetCommandParams & params)
{
params.clear();
if (in.empty())
string const & name, string const & in, InsetCommandParams & params)
{
params.clear();
if (in.empty())
istringstream data(in);
Lexer lex(0,0);
istringstream data(in);
Lexer lex(0,0);
- if (!lex || n != name)
- return print_mailer_error("InsetCommandMailer", in, 1, name);
+ if (!lex || n != name) {
+ print_mailer_error("InsetCommandMailer", in, 1, name);
+ return false;
+ }
// This is part of the inset proper that is usually swallowed
// by Text::readInset
string id;
lex >> id;
// This is part of the inset proper that is usually swallowed
// by Text::readInset
string id;
lex >> id;
- if (!lex || id != "CommandInset")
- return print_mailer_error("InsetCommandMailer", in, 2, "LatexCommand");
+ if (!lex || id != "CommandInset") {
+ print_mailer_error("InsetCommandMailer", in, 2, "LatexCommand");
+ return false;
+ }
virtual std::string const & name() const { return name_; }
///
virtual std::string const inset2string(Buffer const &) const;
virtual std::string const & name() const { return name_; }
///
virtual std::string const inset2string(Buffer const &) const;
- ///
- static void string2params(std::string const &, std::string const & name,
+ /// returns true if params are successfully read
+ static bool string2params(std::string const &, std::string const & name,
InsetCommandParams &);
///
static std::string const params2string(std::string const & name,
InsetCommandParams &);
///
static std::string const params2string(std::string const & name,
explicit InsetCommandParams(std::string const & insetType,
std::string const & cmdName);
///
explicit InsetCommandParams(std::string const & insetType,
std::string const & cmdName);
///
- std::string insetType() { return insetType_; }
+ std::string insetType() const { return insetType_; }
///
void read(Lexer &);
/// Parse the command
///
void read(Lexer &);
/// Parse the command