From c383d6844801026b10bbaef952ce5c3d68866c75 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <alexander.olofsson@liu.se> Date: Fri, 20 Oct 2023 14:30:30 +0200 Subject: [PATCH] Slight error handling improvements --- app/models/orchestration/liudesk_cmdb.rb | 6 +++++- app/views/foreman_liudesk_cmdb/_liudesk_cmdb_facet.html.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/orchestration/liudesk_cmdb.rb b/app/models/orchestration/liudesk_cmdb.rb index 298b79d..32cc6ff 100644 --- a/app/models/orchestration/liudesk_cmdb.rb +++ b/app/models/orchestration/liudesk_cmdb.rb @@ -66,7 +66,11 @@ module Orchestration ::Foreman::Logging.logger("foreman_liudesk_cmdb/sync") .info("Syncing CMDB data for #{name}") - ForemanLiudeskCMDB::SyncAsset::Organizer.call(host: self) + res = ForemanLiudeskCMDB::SyncAsset::Organizer.call(host: self) + unless res.success? + ::Foreman::Logging.logger("foreman_liudesk_cmdb/sync") + .error("Failed to sync CMDB asset for #{name}. #{res.error}") + end rescue StandardError => e ::Foreman::Logging.logger("foreman_liudesk_cmdb/sync") .error("Failed to sync CMDB asset for #{name}. #{e.class}: #{e} - #{e.backtrace}") diff --git a/app/views/foreman_liudesk_cmdb/_liudesk_cmdb_facet.html.erb b/app/views/foreman_liudesk_cmdb/_liudesk_cmdb_facet.html.erb index a5e59fa..c332f17 100644 --- a/app/views/foreman_liudesk_cmdb/_liudesk_cmdb_facet.html.erb +++ b/app/views/foreman_liudesk_cmdb/_liudesk_cmdb_facet.html.erb @@ -3,7 +3,7 @@ asset_data = ForemanLiudeskCMDB::CachedAssetParameters.call(@host, sliced: false asset_keys = %i[network_access_role certificate_information network_certificate_ca] facet = @host.liudesk_cmdb_facet -%> -<div class="additional-info ca w-100">Last synced <span title="<%= facet.sync_at %>"><%= time_ago_in_words(facet.sync_at) %> ago</span> +<div class="additional-info ca w-100">Last synced <span title="<%= facet.sync_at %>"><%= time_ago_in_words(facet.sync_at || Time.at(0)) %> ago</span> <%- if facet.sync_error -%> -- GitLab