From 887cd2398d6eacc6ec52a61d3d8d9dcc7c83336f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 14 May 2018 22:24:03 -0700 Subject: [PATCH] modules/vm: Reorg the main eval exception handlers. --- modules/vm.cc | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/modules/vm.cc b/modules/vm.cc index 0d34c0add..d4d4847fa 100644 --- a/modules/vm.cc +++ b/modules/vm.cc @@ -458,7 +458,27 @@ try return ret; } -catch(const error &e) +catch(const ctx::interrupted &e) // INTERRUPTION +{ + if(eval.opts->errorlog & fault::INTERRUPT) + log::error + { + log, "eval %s: #NMI: %s", + json::get<"event_id"_>(event)?: json::string{""}, + e.what() + }; + + if(eval.opts->warnlog & fault::INTERRUPT) + log::warning + { + log, "eval %s: #NMI: %s", + json::get<"event_id"_>(event)?: json::string{""}, + e.what() + }; + + throw; +} +catch(const error &e) // VM FAULT CODE { if(eval.opts->errorlog & e.code) log::error @@ -483,27 +503,32 @@ catch(const error &e) throw; } -catch(const ctx::interrupted &e) +catch(const m::error &e) // GENERAL MATRIX ERROR { - if(eval.opts->errorlog & fault::INTERRUPT) + if(eval.opts->errorlog & fault::GENERAL) log::error { - log, "eval %s: #NMI: %s", + log, "eval %s: #GP: %s :%s", json::get<"event_id"_>(event)?: json::string{""}, - e.what() + e.what(), + e.content }; - if(eval.opts->warnlog & fault::INTERRUPT) + if(eval.opts->warnlog & fault::GENERAL) log::warning { - log, "eval %s: #NMI: %s", + log, "eval %s: #GP: %s :%s", json::get<"event_id"_>(event)?: json::string{""}, - e.what() + e.what(), + e.content }; + if(eval.opts->nothrows & fault::GENERAL) + return fault::GENERAL; + throw; } -catch(const std::exception &e) +catch(const std::exception &e) // ALL OTHER ERRORS { if(eval.opts->errorlog & fault::GENERAL) log::error