From f79e1a92e3b93bf5c905ffe392242181dd36c68d Mon Sep 17 00:00:00 2001 From: jianghui58 Date: Thu, 24 Feb 2022 11:39:08 +0800 Subject: [PATCH] converter handle unknown error --- mindspore/lite/tools/converter/main.cc | 34 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/mindspore/lite/tools/converter/main.cc b/mindspore/lite/tools/converter/main.cc index a7ae5b14551..2417183620c 100644 --- a/mindspore/lite/tools/converter/main.cc +++ b/mindspore/lite/tools/converter/main.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2020-2022 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,41 @@ * limitations under the License. */ +#if defined(__linux__) && !defined(Debug) +#include +#endif #include "tools/converter/converter.h" + +#if defined(__linux__) && !defined(Debug) +void SignalHandler(int sig) { + printf("encounter an unknown error, please verify the input model file or build the debug version\n"); + exit(0); +} +#endif + namespace mindspore { extern "C" { extern void common_log_init(); } } // namespace mindspore int main(int argc, const char **argv) { - mindspore::common_log_init(); - return mindspore::lite::RunConverter(argc, argv); +#if defined(__linux__) && !defined(Debug) + signal(SIGSEGV, SignalHandler); + signal(SIGABRT, SignalHandler); + signal(SIGFPE, SignalHandler); + signal(SIGBUS, SignalHandler); +#endif + int ret = 0; +#ifndef Debug + try { +#endif + mindspore::common_log_init(); + ret = mindspore::lite::RunConverter(argc, argv); +#ifndef Debug + } catch (const std::exception &e) { + std::cout << e.what() << std::endl; + std::cout << "encounter an unknown error, please verify the input model file or build the debug version\n"; + } +#endif + return ret; }