produce a better error message when a category/function is not in the abstract

This commit is contained in:
Krasimir Angelov
2026-09-21 10:55:00 +02:00
parent e0fe461b3e
commit dc1808d940
2 changed files with 24 additions and 12 deletions
-9
View File
@@ -38,16 +38,7 @@ class PGF_INTERNAL_DECL pgf_error : public std::runtime_error {
public:
pgf_error(const char *msg) : std::runtime_error(msg)
{
this->msg = msg;
}
virtual const char *what() const throw ()
{
return msg;
}
private:
const char *msg;
};
class PGF_INTERNAL_DECL pgf_systemerror : public std::runtime_error {
+24 -3
View File
@@ -2304,7 +2304,14 @@ void pgf_create_lincat(PgfDB *db,
ref<PgfAbsCat> abscat =
namespace_lookup(pgf->abstract.cats, name);
if (abscat == 0) {
throw pgf_error("There is no corresponding category in the abstract syntax");
PgfPrinter printer(NULL, 0, NULL);
printer.puts("Category ");
printer.efun(name);
printer.puts(" is not defined in the abstract syntax");
PgfText *msg = printer.get_text();
pgf_error err = pgf_error(msg->text);
free(msg);
throw err;
}
ref<PgfConcrLincat> lincat =
@@ -2373,7 +2380,14 @@ void pgf_create_lin(PgfDB *db,
ref<PgfAbsFun> absfun =
namespace_lookup(pgf->abstract.funs, name);
if (absfun == 0) {
throw pgf_error("There is no corresponding function in the abstract syntax");
PgfPrinter printer(NULL, 0, NULL);
printer.puts("Function ");
printer.efun(name);
printer.puts(" is not defined in the abstract syntax");
PgfText *msg = printer.get_text();
pgf_error err = pgf_error(msg->text);
free(msg);
throw err;
}
ref<PgfConcrLin> lin =
@@ -2406,7 +2420,14 @@ void pgf_alter_lin(PgfDB *db,
ref<PgfAbsFun> absfun =
namespace_lookup(pgf->abstract.funs, name);
if (absfun == 0) {
throw pgf_error("There is no corresponding function in the abstract syntax");
PgfPrinter printer(NULL, 0, NULL);
printer.puts("Function ");
printer.efun(name);
printer.puts(" is not defined in the abstract syntax");
PgfText *msg = printer.get_text();
pgf_error err = pgf_error(msg->text);
free(msg);
throw err;
}
ref<PgfConcrLin> lin =