summaryrefslogtreecommitdiffstats
path: root/src/lib/netlist/prg/nltool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/prg/nltool.cpp')
-rw-r--r--src/lib/netlist/prg/nltool.cpp90
1 files changed, 51 insertions, 39 deletions
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp
index fdfd5ed7a94..31cb8af00f6 100644
--- a/src/lib/netlist/prg/nltool.cpp
+++ b/src/lib/netlist/prg/nltool.cpp
@@ -145,9 +145,10 @@ protected:
void vlog(const plib::plog_level &l, const pstring &ls) const override
{
- pout("{}: {}\n", l.name().cstr(), ls.cstr());
+ pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.cstr());
+ pout("{}", err);
if (l == plib::plog_level::FATAL)
- throw std::exception();
+ throw netlist::nl_exception(err);
}
private:
@@ -179,7 +180,7 @@ struct input_t
double t;
int e = sscanf(line.cstr(), "%lf,%[^,],%lf", &t, buf, &m_value);
if ( e!= 3)
- throw netlist::fatalerror_e(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
+ throw netlist::nl_exception(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
m_time = netlist::netlist_time::from_double(t);
m_param = setup.find_param(buf, true);
}
@@ -190,7 +191,7 @@ struct input_t
{
case netlist::param_t::MODEL:
case netlist::param_t::STRING:
- throw netlist::fatalerror_e(plib::pfmt("param {1} is not numeric\n")(m_param->name()));
+ throw netlist::nl_exception(plib::pfmt("param {1} is not numeric\n")(m_param->name()));
case netlist::param_t::DOUBLE:
static_cast<netlist::param_double_t*>(m_param)->setTo(m_value);
break;
@@ -432,50 +433,61 @@ int main(int argc, char *argv[])
return 0;
}
- pstring cmd = opts.opt_cmd();
- if (cmd == "listdevices")
- listdevices(opts);
- else if (cmd == "run")
- run(opts);
- else if (cmd == "static")
- static_compile(opts);
- else if (cmd == "convert")
+ try
{
- pstring contents;
- plib::postringstream ostrm;
- if (opts.opt_file() == "-")
+ pstring cmd = opts.opt_cmd();
+ if (cmd == "listdevices")
+ listdevices(opts);
+ else if (cmd == "run")
+ run(opts);
+ else if (cmd == "static")
+ static_compile(opts);
+ else if (cmd == "convert")
{
- plib::pstdin f;
- ostrm.write(f);
- }
- else
- {
- plib::pifilestream f(opts.opt_file());
- ostrm.write(f);
- }
- contents = ostrm.str();
+ pstring contents;
+ plib::postringstream ostrm;
+ if (opts.opt_file() == "-")
+ {
+ plib::pstdin f;
+ ostrm.write(f);
+ }
+ else
+ {
+ plib::pifilestream f(opts.opt_file());
+ ostrm.write(f);
+ }
+ contents = ostrm.str();
- pstring result;
- if (opts.opt_type().equals("spice"))
- {
- nl_convert_spice_t c;
- c.convert(contents);
- result = c.result();
+ pstring result;
+ if (opts.opt_type().equals("spice"))
+ {
+ nl_convert_spice_t c;
+ c.convert(contents);
+ result = c.result();
+ }
+ else
+ {
+ nl_convert_eagle_t c;
+ c.convert(contents);
+ result = c.result();
+ }
+ /* present result */
+ pout_strm.write(result.cstr());
}
else
{
- nl_convert_eagle_t c;
- c.convert(contents);
- result = c.result();
+ perr("Unknown command {}\n", cmd.cstr());
+ usage(opts);
+ return 1;
}
- /* present result */
- pout_strm.write(result.cstr());
}
- else
+ catch (netlist::nl_exception &e)
{
- perr("Unknown command {}\n", cmd.cstr());
- usage(opts);
- return 1;
+ perr("Netlist exception caught: {}\n", e.text());
+ }
+ catch (plib::pexception &e)
+ {
+ perr("plib exception caught: {}\n", e.text());
}
pstring::resetmem();