打开设备时增加异常处理,使JSON配置异常时能够快速退出,并返回报内部数据错误
This commit is contained in:
parent
49cb1e71b5
commit
0b41d9f30a
|
@ -3120,7 +3120,7 @@ int hg_scanner::set_setting_value(const char* name, void* data, long* len)
|
|||
}
|
||||
int hg_scanner::on_scanner_closing(bool force)
|
||||
{
|
||||
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
||||
return SCANNER_ERR_OK;
|
||||
}
|
||||
|
||||
void hg_scanner::thread_handle_usb_read(void)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <string.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <exception>
|
||||
|
||||
|
||||
#define MAKE_VERSION(a, b, c, d) \
|
||||
|
@ -137,9 +138,28 @@ extern "C"
|
|||
}
|
||||
|
||||
scanner_err hg_scanner_open(scanner_handle* h, const char* name, bool shared, const char* user, const char* pwd, const char* check, char* rsc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return hg_scanner_mgr::instance()->hg_scanner_open(h, name, shared, user, pwd, check, rsc);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
if (h)
|
||||
*h = nullptr;
|
||||
VLOG_MINI_2(LOG_LEVEL_FATAL, "Exception occurs when open '%s': %s.\n", name, e.what());
|
||||
|
||||
return SCANNER_ERR_DATA_DAMAGED;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (h)
|
||||
*h = nullptr;
|
||||
VLOG_MINI_1(LOG_LEVEL_FATAL, "Exception occurs when open '%s'!\n", name);
|
||||
|
||||
return SCANNER_ERR_DATA_DAMAGED;
|
||||
}
|
||||
}
|
||||
|
||||
scanner_err hg_scanner_close(scanner_handle h, bool force)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue