{"id":303,"date":"2018-07-31T20:51:23","date_gmt":"2018-07-31T19:51:23","guid":{"rendered":"http:\/\/controlsoftwaresolutions.com\/?p=303"},"modified":"2018-07-31T20:51:23","modified_gmt":"2018-07-31T19:51:23","slug":"error-handling-strategies-labview","status":"publish","type":"post","link":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/","title":{"rendered":"Error handling strategies in LabVIEW"},"content":{"rendered":"

David Maidman –\u00a0 Control Software Solutions<\/strong><\/p>\n

Introduction<\/h1>\n

Error handling is an essential part of a professional LabVIEW application, however is something that is often overlooked. Without adequate error handling applications can be hard to debug, provide a bad user experience and in the worst case can cause damage to equipment, loss of data and even injury.<\/p>\n

When starting out with LabVIEW one of the first things we are taught is the importance of error handling. In these early days the general advice is that we should always enclose block diagram code in an error case and that we should always wire errors between our subVIs. However, in practice this advice does not always provide an adequate error handling strategy when creating professional applications, and in some circumstances causes more problems than it solves.<\/p>\n

Local Error Handling<\/h1>\n

Often when an error occurs, rather than passing it downstream it can be dealt with there and then. How you handle the error depends on the specific error and the software requirements. Often when an error occurs we might decide to handle it locally by one of three ways; ignore it, modify it, or retry.<\/p>\n

Ignore<\/h2>\n

Sometimes it is possible to simply ignore an upstream error. One common example might be a communications timeout error when reading from a TCP connection. In the case of a timeout the read VI returns an error because it failed to successfully carry out its primary job, however in the context of your application this might not be seen as an error and therefore it can be cleared (for example it could be that there are no messages to read).<\/p>\n

\"\"<\/p>\n

Figure 1 clearing a timeout error<\/em><\/p>\n

\"\"<\/a><\/p>\n

Figure 2 example of how a specific error can be cleared<\/em><\/p>\n

Modify<\/h2>\n

Some errors may provide information that can be used downstream, even if you do not consider them to be errors. In this case you could choose to downgrade an error to a warning. In this case the error cluster retains the useful information, however does not prevent downstream code from executing. One example would be when creating a new directory: if the directory already exists an error will be generated, however if the reason you are creating the directory is simply to ensure that it exists then you might not want an error to be generated.<\/p>\n

\"\"<\/a><\/p>\n

Figure 3 downgrading an error to a warning<\/em><\/p>\n

Another reason you might want to modify an error is to change the error code to one specific to your application.<\/p>\n

\"\"<\/p>\n

Figure 4 changing a default error code to one specific for the application<\/em><\/p>\n

Retry<\/h2>\n

Sometimes you might only be interested in an error if it occurs a number of times. An example might be when attempting to initialise a DAQ device when the device has not been connected. In this example you might clear the error and then retry.<\/p>\n

\"\"<\/a><\/p>\n

Figure 5 implementing a ‘retry on error’ strategy<\/em><\/p>\n

Asynchronous Error Handling<\/h1>\n

You might not always want to handle errors locally and therefore it might be necessary to pass error information to another module to be handled. In this case you can use queued message handlers if you have a dedicated error handling module, or by user events if you want modules (for example a state controller or user interface) to subscribe to error messages.<\/p>\n

\"\"<\/a><\/p>\n

Figure 6 adding errors to a queue to handle in another loop<\/em><\/p>\n

 <\/p>\n

\"\"<\/a><\/p>\n

Figure 7 publishing errors as events to be handled by subscribing processes<\/em><\/p>\n

In practice you are likely to use a combination of local and central error handling depending on the requirements of your project.<\/p>\n

Error Handling Guidelines<\/h1>\n
    \n
  1. Before enclosing the block diagram of a VI in an error case consider as yourself the question \u2018should the code in this VI run if there is an upstream error?\u2019 Only if the answer is \u2018No\u2019 should you enclose the code in an error case.<\/li>\n
  2. In general shutdown code should always execute, therefore do not enclose the code within an error case, rather merge the input error with the error stream at the output of the subVI.<\/li>\n
  3. Remember to maintain separate error streams for unrelated functions.<\/li>\n
  4. If possible handle errors where they occur.<\/li>\n
  5. Consider what you what you want to happen in the event of an error (ignore, retry, modify).<\/li>\n
  6. Errors can provide useful information – downgrade to warnings if you want to maintain the error information without triggering an error.<\/li>\n
  7. Handle errors gracefully and always avoid crashing the application when an error occurs.<\/li>\n
  8. Log unhandled errors to allow useful debug information.<\/li>\n
  9. Always consider error handling in the requirements and detailed design phase of your project.<\/li>\n<\/ol>\n

    \"\"<\/a><\/p>\n

    Figure 8 do not enclose shutdown code in an error case<\/em><\/p>\n

     <\/p>\n

    \"\"<\/a><\/p>\n

    Figure 9 merging incoming errors with the output error stream to ensure the shutdown code executes<\/em><\/p>\n

    Further Information<\/h2>\n

    For more information on any of the topics you have read in this article, or for more information on LabVIEW programming\u00a0contact us<\/a>:<\/p>\n","protected":false},"excerpt":{"rendered":"

    David Maidman –\u00a0 Control Software Solutions Introduction Error handling is an essential part of a professional LabVIEW application, however is something that is often overlooked. Without adequate error handling applications … more →<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":""},"categories":[14],"tags":[15],"acf":[],"yoast_head":"\nError handling strategies in LabVIEW - Control Software Solutions<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Error handling strategies in LabVIEW - Control Software Solutions\" \/>\n<meta property=\"og:description\" content=\"David Maidman –\u00a0 Control Software Solutions Introduction Error handling is an essential part of a professional LabVIEW application, however is something that is often overlooked. Without adequate error handling applications … more →\" \/>\n<meta property=\"og:url\" content=\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/\" \/>\n<meta property=\"og:site_name\" content=\"Control Software Solutions\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/controlsoftwaresolutions\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-31T19:51:23+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/controlsoftwaresolutions.com\/wp-content\/uploads\/2018\/07\/clear-timeout.png\" \/>\n<meta name=\"author\" content=\"David Maidman\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"David Maidman\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/\"},\"author\":{\"name\":\"David Maidman\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#\/schema\/person\/d85e9efafed0786d9aad67a56235ff62\"},\"headline\":\"Error handling strategies in LabVIEW\",\"datePublished\":\"2018-07-31T19:51:23+00:00\",\"dateModified\":\"2018-07-31T19:51:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/\"},\"wordCount\":813,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#organization\"},\"keywords\":[\"LabVIEW error handling\"],\"articleSection\":[\"Software Development\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/\",\"url\":\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/\",\"name\":\"Error handling strategies in LabVIEW - Control Software Solutions\",\"isPartOf\":{\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#website\"},\"datePublished\":\"2018-07-31T19:51:23+00:00\",\"dateModified\":\"2018-07-31T19:51:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/controlsoftwaresolutions.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Error handling strategies in LabVIEW\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#website\",\"url\":\"https:\/\/controlsoftwaresolutions.com\/\",\"name\":\"Control Software Solutions\",\"description\":\"CSS\",\"publisher\":{\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/controlsoftwaresolutions.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#organization\",\"name\":\"Control Software Solutions\",\"url\":\"https:\/\/controlsoftwaresolutions.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i0.wp.com\/controlsoftwaresolutions.com\/wp-content\/uploads\/2017\/10\/control_software_solutions_logo.png?fit=274%2C75&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/controlsoftwaresolutions.com\/wp-content\/uploads\/2017\/10\/control_software_solutions_logo.png?fit=274%2C75&ssl=1\",\"width\":274,\"height\":75,\"caption\":\"Control Software Solutions\"},\"image\":{\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/controlsoftwaresolutions\",\"https:\/\/twitter.com\/CssControl\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#\/schema\/person\/d85e9efafed0786d9aad67a56235ff62\",\"name\":\"David Maidman\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/controlsoftwaresolutions.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eee371a6a41d9dc304f25ca5059db72f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eee371a6a41d9dc304f25ca5059db72f?s=96&d=mm&r=g\",\"caption\":\"David Maidman\"},\"sameAs\":[\"http:\/\/www.controlsoftwaresolutions.com\"],\"url\":\"https:\/\/controlsoftwaresolutions.com\/author\/davidm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Error handling strategies in LabVIEW - Control Software Solutions","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:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/","og_locale":"en_GB","og_type":"article","og_title":"Error handling strategies in LabVIEW - Control Software Solutions","og_description":"David Maidman –\u00a0 Control Software Solutions Introduction Error handling is an essential part of a professional LabVIEW application, however is something that is often overlooked. Without adequate error handling applications … more →","og_url":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/","og_site_name":"Control Software Solutions","article_publisher":"https:\/\/www.facebook.com\/controlsoftwaresolutions","article_published_time":"2018-07-31T19:51:23+00:00","og_image":[{"url":"http:\/\/controlsoftwaresolutions.com\/wp-content\/uploads\/2018\/07\/clear-timeout.png"}],"author":"David Maidman","twitter_misc":{"Written by":"David Maidman","Estimated reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#article","isPartOf":{"@id":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/"},"author":{"name":"David Maidman","@id":"https:\/\/controlsoftwaresolutions.com\/#\/schema\/person\/d85e9efafed0786d9aad67a56235ff62"},"headline":"Error handling strategies in LabVIEW","datePublished":"2018-07-31T19:51:23+00:00","dateModified":"2018-07-31T19:51:23+00:00","mainEntityOfPage":{"@id":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/"},"wordCount":813,"commentCount":1,"publisher":{"@id":"https:\/\/controlsoftwaresolutions.com\/#organization"},"keywords":["LabVIEW error handling"],"articleSection":["Software Development"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/","url":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/","name":"Error handling strategies in LabVIEW - Control Software Solutions","isPartOf":{"@id":"https:\/\/controlsoftwaresolutions.com\/#website"},"datePublished":"2018-07-31T19:51:23+00:00","dateModified":"2018-07-31T19:51:23+00:00","breadcrumb":{"@id":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/controlsoftwaresolutions.com\/error-handling-strategies-labview\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/controlsoftwaresolutions.com\/"},{"@type":"ListItem","position":2,"name":"Error handling strategies in LabVIEW"}]},{"@type":"WebSite","@id":"https:\/\/controlsoftwaresolutions.com\/#website","url":"https:\/\/controlsoftwaresolutions.com\/","name":"Control Software Solutions","description":"CSS","publisher":{"@id":"https:\/\/controlsoftwaresolutions.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/controlsoftwaresolutions.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/controlsoftwaresolutions.com\/#organization","name":"Control Software Solutions","url":"https:\/\/controlsoftwaresolutions.com\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/controlsoftwaresolutions.com\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/controlsoftwaresolutions.com\/wp-content\/uploads\/2017\/10\/control_software_solutions_logo.png?fit=274%2C75&ssl=1","contentUrl":"https:\/\/i0.wp.com\/controlsoftwaresolutions.com\/wp-content\/uploads\/2017\/10\/control_software_solutions_logo.png?fit=274%2C75&ssl=1","width":274,"height":75,"caption":"Control Software Solutions"},"image":{"@id":"https:\/\/controlsoftwaresolutions.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/controlsoftwaresolutions","https:\/\/twitter.com\/CssControl"]},{"@type":"Person","@id":"https:\/\/controlsoftwaresolutions.com\/#\/schema\/person\/d85e9efafed0786d9aad67a56235ff62","name":"David Maidman","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/controlsoftwaresolutions.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eee371a6a41d9dc304f25ca5059db72f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eee371a6a41d9dc304f25ca5059db72f?s=96&d=mm&r=g","caption":"David Maidman"},"sameAs":["http:\/\/www.controlsoftwaresolutions.com"],"url":"https:\/\/controlsoftwaresolutions.com\/author\/davidm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7rmHJ-4T","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/posts\/303"}],"collection":[{"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/comments?post=303"}],"version-history":[{"count":11,"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/posts\/303\/revisions"}],"predecessor-version":[{"id":324,"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/posts\/303\/revisions\/324"}],"wp:attachment":[{"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/media?parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/categories?post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/controlsoftwaresolutions.com\/wp-json\/wp\/v2\/tags?post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}