From b691a256d792cc7f421006309fff3102838f2646 Mon Sep 17 00:00:00 2001 From: Yongjoo Ahn Date: Wed, 22 Mar 2023 17:09:02 +0900 Subject: [PATCH] [agent] Print exception message - Print exception message rather than simple error log Signed-off-by: Yongjoo Ahn --- daemon/model-dbus-impl.cc | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/daemon/model-dbus-impl.cc b/daemon/model-dbus-impl.cc index f6e0751..dc7df5f 100644 --- a/daemon/model-dbus-impl.cc +++ b/daemon/model-dbus-impl.cc @@ -66,8 +66,11 @@ gdbus_cb_model_register (MachinelearningServiceModel *obj, try { db.connectDB (); db.set_model (name, path, is_active, description, &version); - } catch (...) { - g_critical ("DB error occurred. Failed to register the model: %s", name); + } catch (const std::invalid_argument &e) { + g_critical ("%s", e.what ()); + ret = -EINVAL; + } catch (const std::exception &e) { + g_critical ("%s", e.what ()); ret = -EIO; } @@ -101,10 +104,10 @@ gdbus_cb_model_update_description (MachinelearningServiceModel *obj, db.connectDB (); db.update_model_description (name, version, description); } catch (const std::invalid_argument &e) { - g_critical ("There is no such model"); + g_critical ("%s", e.what ()); ret = -EINVAL; - } catch (...) { - g_critical ("DB error occurred. Failed to update the model description: %s", name); + } catch (const std::exception &e) { + g_critical ("%s", e.what ()); ret = -EIO; } @@ -136,10 +139,10 @@ gdbus_cb_model_activate (MachinelearningServiceModel *obj, db.connectDB (); db.activate_model (name, version); } catch (const std::invalid_argument &e) { - g_critical ("There is no such model"); + g_critical ("%s", e.what ()); ret = -EINVAL; - } catch (...) { - g_critical ("DB error occurred. Failed to activate the model: %s", name); + } catch (const std::exception &e) { + g_critical ("%s", e.what ()); ret = -EIO; } @@ -171,10 +174,10 @@ gdbus_cb_model_get (MachinelearningServiceModel *obj, db.connectDB (); db.get_model (name, model_info, version); } catch (const std::invalid_argument &e) { - g_critical ("There is no active model"); + g_critical ("%s", e.what ()); ret = -EINVAL; - } catch (...) { - g_critical ("DB error occurred. Failed to get the active model: %s", name); + } catch (const std::exception &e) { + g_critical ("%s", e.what ()); ret = -EIO; } @@ -205,10 +208,10 @@ gdbus_cb_model_get_activated (MachinelearningServiceModel *obj, db.connectDB (); db.get_model (name, model_info, -1); } catch (const std::invalid_argument &e) { - g_critical ("There is no active model"); + g_critical ("%s", e.what ()); ret = -EINVAL; - } catch (...) { - g_critical ("DB error occurred. Failed to get the active model: %s", name); + } catch (const std::exception &e) { + g_critical ("%s", e.what ()); ret = -EIO; } @@ -240,10 +243,10 @@ gdbus_cb_model_get_all (MachinelearningServiceModel *obj, db.connectDB (); db.get_model (name, all_model_list, 0); } catch (const std::invalid_argument &e) { - g_critical ("There is no such model"); + g_critical ("%s", e.what ()); ret = -EINVAL; - } catch (...) { - g_critical ("DB error occurred. Failed to get all the models"); + } catch (const std::exception &e) { + g_critical ("%s", e.what ()); ret = -EIO; } @@ -276,10 +279,10 @@ gdbus_cb_model_delete (MachinelearningServiceModel *obj, db.connectDB (); db.delete_model (name, version); } catch (const std::invalid_argument &e) { - g_critical ("There is no such model"); + g_critical ("%s", e.what ()); ret = -EINVAL; - } catch (...) { - g_critical ("DB error occurred. Failed to delete the model: %s", name); + } catch (const std::exception &e) { + g_critical ("%s", e.what ()); ret = -EIO; } -- 2.7.4