{"id":1554,"date":"2020-05-05T11:46:16","date_gmt":"2020-05-05T11:46:16","guid":{"rendered":"https:\/\/wetransform.eu\/?post_type=news-and-events&#038;p=1554"},"modified":"2022-07-28T08:13:00","modified_gmt":"2022-07-28T08:13:00","slug":"groovy-logging-error-handling","status":"publish","type":"news-and-events","link":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/","title":{"rendered":"Groovy Week 2020: Logging and Error Handling"},"content":{"rendered":"<p>In our second installment of the 2020 Groovy Week, we are going to cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised, e.g. due to incomplete or unexpected source data. Like the previous post, note that this article assumes you have working knowledge of hale\u00bbstudio and know the terminology.<\/p>\n<h2>Tuesday's Script: Handling and logging Errors and other relevant information (Florian)<\/h2>\n<p>When using a Groovy script for a specific mapping task, you often need to add checks that verify that the incoming source data can actually be transformed correctly. In cases where the transformation cannot proceed (e.g. because of missing or erroneous source data), the cause needs to be reported. To achieve that, you can add <em>error<\/em>, <em>warning<\/em> and <em>informational<\/em> messages to the transformation log as well as throw exceptions to signal a critical error.<\/p>\n<p>The following script is part of an alignment that transforms road data to the INSPIRE Transport Network Roads schema. It first defines two conditions <code>hatFahrbahnachse<\/code> and <code>hatStrassenachse<\/code> based on if the source instance contains a link to a <code>AX_Fahrbahnachse<\/code> or <code>AX_Strassenachse<\/code> source instance. If neither condition is met, the transformation cannot proceed. An error message is added to the transformation log and a <code>NoResultException<\/code> is thrown to indicate that the script did not create a result in this case, which is a critical error.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JBoudewijn\/f8638a9a05037df3b470af1611349739.js\"><\/script><\/p>\n<p>Not all situations are equally critical, of course. If a warning or informational message is sufficient, use one of the two other log levels that are supported by hale studio: <em>warning<\/em> and <em>info<\/em>. To emit a warning to the transformation log, use <code>_log.warn<\/code>. For informational messages, use <code>_log.info<\/code>.<\/p>\n<p>All messages emitted from a Groovy script can be accessed in hale studio via the &quot;Instance transformation&quot; entry of a transformation run in the &quot;Report List&quot;, as shown in the following picture:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/transformation-log-messages.png\" alt=\"hale\u00bbstudio report list\" \/><\/p>\n<p>You can download the script snippet <a href=\"https:\/\/github.com\/wetransform-os\/website-examples\/blob\/af7108ee8f5a838327c3e4b871850212c399e37c\/news\/resources\/loggingErrorHandling.groovy\" title=\"here\">here<\/a> and import it in hale\u00bbstudio as a Groovy snippet by going to File -&gt; Import -&gt; Groovy Snippet. Please note that some scripts use protected functions, so you might need to &quot;Lift Groovy Restrictions&quot; to execute the script. Make sure you replace the placeholder attribute names with your own attribute names.<\/p>\n<p>Happy transforming!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our second installment of the 2020 Groovy Week, we are going to cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised, e.g. due to incomplete or unexpected source data. Like the previous post, note that this article assumes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[48],"tags":[47,21,46],"class_list":["post-1554","news-and-events","type-news-and-events","status-publish","hentry","category-tutorials","tag-groovy","tag-halestudio","tag-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Groovy Week 2020: Logging and Error Handling - wetransform<\/title>\n<meta name=\"description\" content=\"We cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Groovy Week 2020: Logging and Error Handling\" \/>\n<meta property=\"og:description\" content=\"We cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/\" \/>\n<meta property=\"og:site_name\" content=\"wetransform\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-28T08:13:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/transformation-log-messages.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@wetransformto\" \/>\n<meta name=\"twitter:label1\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data1\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/\",\"url\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/\",\"name\":\"Groovy Week 2020: Logging and Error Handling - wetransform\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wetransform.eu\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/transformation-log-messages.png\",\"datePublished\":\"2020-05-05T11:46:16+00:00\",\"dateModified\":\"2022-07-28T08:13:00+00:00\",\"description\":\"We cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wetransform.eu\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/transformation-log-messages.png\",\"contentUrl\":\"https:\\\/\\\/wetransform.eu\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/transformation-log-messages.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/groovy-logging-error-handling\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wetransform.to\\\/de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"News & Events\",\"item\":\"https:\\\/\\\/wetransform.to\\\/de\\\/neuigkeiten-veranstaltungen\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Groovy Week 2020: Logging and Error Handling\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#website\",\"url\":\"http:\\\/\\\/wetransform.to\\\/de\\\/\",\"name\":\"wetransform\",\"description\":\"Making environmental data useful and accessible\",\"publisher\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/wetransform.to\\\/de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#organization\",\"name\":\"wetransform\",\"url\":\"http:\\\/\\\/wetransform.to\\\/de\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wetransform.to\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/large-logo-whitebg.png\",\"contentUrl\":\"https:\\\/\\\/wetransform.to\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/large-logo-whitebg.png\",\"width\":1024,\"height\":1024,\"caption\":\"wetransform\"},\"image\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/wetransformto\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/wetransform-gmbh\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Groovy Week 2020: Logging and Error Handling - wetransform","description":"We cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/","og_locale":"de_DE","og_type":"article","og_title":"Groovy Week 2020: Logging and Error Handling","og_description":"We cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised.","og_url":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/","og_site_name":"wetransform","article_modified_time":"2022-07-28T08:13:00+00:00","og_image":[{"url":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/transformation-log-messages.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@wetransformto","twitter_misc":{"Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/","url":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/","name":"Groovy Week 2020: Logging and Error Handling - wetransform","isPartOf":{"@id":"http:\/\/wetransform.to\/de\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/#primaryimage"},"image":{"@id":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/#primaryimage"},"thumbnailUrl":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/transformation-log-messages.png","datePublished":"2020-05-05T11:46:16+00:00","dateModified":"2022-07-28T08:13:00+00:00","description":"We cover the topic of adding messages to the transformation log as well as showing how to handle situations where an error needs to be raised.","breadcrumb":{"@id":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/#primaryimage","url":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/transformation-log-messages.png","contentUrl":"https:\/\/wetransform.eu\/wp-content\/uploads\/2022\/05\/transformation-log-messages.png"},{"@type":"BreadcrumbList","@id":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/groovy-logging-error-handling\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wetransform.to\/de\/"},{"@type":"ListItem","position":2,"name":"News & Events","item":"https:\/\/wetransform.to\/de\/neuigkeiten-veranstaltungen\/"},{"@type":"ListItem","position":3,"name":"Groovy Week 2020: Logging and Error Handling"}]},{"@type":"WebSite","@id":"http:\/\/wetransform.to\/de\/#website","url":"http:\/\/wetransform.to\/de\/","name":"wetransform","description":"Making environmental data useful and accessible","publisher":{"@id":"http:\/\/wetransform.to\/de\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/wetransform.to\/de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"http:\/\/wetransform.to\/de\/#organization","name":"wetransform","url":"http:\/\/wetransform.to\/de\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"http:\/\/wetransform.to\/de\/#\/schema\/logo\/image\/","url":"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/07\/large-logo-whitebg.png","contentUrl":"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/07\/large-logo-whitebg.png","width":1024,"height":1024,"caption":"wetransform"},"image":{"@id":"http:\/\/wetransform.to\/de\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/wetransformto","https:\/\/www.linkedin.com\/company\/wetransform-gmbh\/"]}]}},"_links":{"self":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events"}],"about":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/types\/news-and-events"}],"author":[{"embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/comments?post=1554"}],"version-history":[{"count":4,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1554\/revisions"}],"predecessor-version":[{"id":3757,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1554\/revisions\/3757"}],"wp:attachment":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/media?parent=1554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/categories?post=1554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/tags?post=1554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}