From a119b36f720084f4955fe35d6049bf064febec29 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Tue, 12 Jun 2018 23:08:28 +0800 Subject: [PATCH] Catch process exception --- src/api/processor/processor.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/api/processor/processor.cc b/src/api/processor/processor.cc index 75e5e9e..7d88bc9 100644 --- a/src/api/processor/processor.cc +++ b/src/api/processor/processor.cc @@ -15,8 +15,10 @@ #include +#include #include +#include "internal/strings.h" #include "internal/times.h" MYNTEYE_BEGIN_NAMESPACE @@ -192,14 +194,21 @@ void Processor::Run() { pre_callback_(input_.get()); } bool ok = false; - if (callback_) { - if (callback_(input_.get(), output_.get(), parent_)) { - ok = true; + try { + if (callback_) { + if (callback_(input_.get(), output_.get(), parent_)) { + ok = true; + } else { + ok = OnProcess(input_.get(), output_.get(), parent_); + } } else { ok = OnProcess(input_.get(), output_.get(), parent_); } - } else { - ok = OnProcess(input_.get(), output_.get(), parent_); + // CV_Assert(false); + } catch (const std::exception &e) { + std::string msg(e.what()); + strings::rtrim(msg); + LOG(ERROR) << Name() << " process error \"" << msg << "\""; } if (!ok) { VLOG(2) << Name() << " process failed";