{"id":18,"date":"2018-05-19T11:00:00","date_gmt":"2018-05-19T11:00:00","guid":{"rendered":"http:\/\/nkascocom.nk\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/"},"modified":"2018-05-19T11:00:00","modified_gmt":"2018-05-19T11:00:00","slug":"2018-5-13-properly-using-trycatch-to-handle-errors","status":"publish","type":"post","link":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/","title":{"rendered":"Properly using try\/catch to handle errors"},"content":{"rendered":"<div class=\"sqs-html-content\">\n<p>Error handling is easily one of the most overlooked things about Powershell in my opinion, it seems like I see a ton of well written scripts with just improper error handling, but why? It&#8217;s actually not that hard of a concept, until you aren&#8217;t sure whether or not something produces a terminating error&#8230; Unless you know 1 extremely simple tip:<\/p>\n<p>First let&#8217;s briefly breakdown the syntax, you generally only need a <strong>try\/catch<\/strong> and the two are mutually inclusive, i.e. anytime you use try you must use catch as well, both just wrap your code in scriptblocks. The try block is simply where you are executing your code, and <em>if <\/em>there is a terminating error your code automatically stops at it&#8217;s point in the try block and falls to the catch scriptblock to handle your error as desired. Here is a quick example:<\/p>\n<pre>try{\n&nbsp;&nbsp;&nbsp; $ProfilePaths = (Get-CimInstance win32_userprofilse -ErrorAction SilentlyContinue).LocalPath\n} catch {\n&nbsp;&nbsp;&nbsp; Write-Host -ForegroundColor Red \"Error: Unable to query user profiles\"\n}<\/pre>\n<p>So if you haven&#8217;t noticed already you can see that we mistyped our class name. Therefore if we run our code in theory we should fall to our catch block, right? Well, here is the output of this code:<\/p>\n<\/div>\n<div\n        class=\"\n          image-block-outer-wrapper\n          layout-caption-hidden\n          design-layout-inline\n          \n          \n          \n        \"\n        data-test=\"image-block-inline-outer-wrapper\"\n    ><\/p>\n<figure\n            class=\"\n              sqs-block-image-figure\n              intrinsic\n            \"\n            style=\"max-width:699px;\"\n        ><\/p>\n<p>            <button\n                class=\"\n                  sqs-block-image-button\n                  lightbox\n                  \n          \n        \n                \"\n                data-description=\"\"\n                data-lightbox-theme=\"dark\"\n            ><br \/>\n              <span class=\"v6-visually-hidden\">View fullsize<\/span><\/p>\n<div\n              \n              \n              class=\"image-block-wrapper\"\n              data-animation-role=\"image\"\n              \n  data-animation-override\n\n          ><\/p>\n<div class=\"sqs-image-shape-container-element\n              \n          \n        \n              has-aspect-ratio\n            \" style=\"\n                position: relative;\n                \n                  padding-bottom:18.597997665405273%;\n                \n                overflow: hidden;-webkit-mask-image: -webkit-radial-gradient(white, black);\n              \"\n              ><\/p>\n<p>                  <img loading=\"lazy\" data-stretch=\"false\" src=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\" data-image=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\" data-image-dimensions=\"699x130\" data-image-focal-point=\"0.5,0.5\" alt=\"output1.png\" data-load=\"false\" elementtiming=\"system-image-block\" src=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\" width=\"699\" height=\"130\" alt=\"\" sizes=\"auto, (max-width: 640px) 100vw, (max-width: 767px) 100vw, 100vw\" style=\"display:block;object-fit: cover; width: 100%; height: 100%; object-position: 50% 50%\" onload=\"this.classList.add(&quot;loaded&quot;)\" srcset=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png?format=100w 100w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png?format=300w 300w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png?format=500w 500w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png?format=750w 750w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png?format=1000w 1000w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png?format=1500w 1500w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png?format=2500w 2500w\" loading=\"lazy\" decoding=\"async\" data-loader=\"sqs\"><\/p><\/div>\n<\/p><\/div>\n<p>            <\/button><\/p>\n<\/figure><\/div>\n<div class=\"sqs-html-content\">\n<p>That&#8217;s not right, it ran the code but didn&#8217;t display our error. That&#8217;s because our Get-CimInstance cmdlet didn&#8217;t produce a terminating error. Luckily, by using <strong>throw<\/strong> within our try block we can force it to fall to the catch block. Therefore since we are capturing the output of our command to a variable we can simply test to see if we have an empty variable or not. Let&#8217;s take a look at what our code looks like now:<\/p>\n<pre>try{\n&nbsp;&nbsp;&nbsp; $ProfilePaths = (Get-CimInstance win32_userprofilse -ErrorAction SilentlyContinue).LocalPath\n\n&nbsp;&nbsp;&nbsp; if(!$ProfilePaths){ throw }\n} catch {\n&nbsp;&nbsp;&nbsp; Write-Host -ForegroundColor Red \"Error: Unable to query user profiles\"\n}<\/pre>\n<p>So now if we run this code we get the error message we were expecting:<\/p>\n<\/div>\n<div\n        class=\"\n          image-block-outer-wrapper\n          layout-caption-hidden\n          design-layout-inline\n          \n          \n          \n        \"\n        data-test=\"image-block-inline-outer-wrapper\"\n    ><\/p>\n<figure\n            class=\"\n              sqs-block-image-figure\n              intrinsic\n            \"\n            style=\"max-width:694px;\"\n        ><\/p>\n<p>            <button\n                class=\"\n                  sqs-block-image-button\n                  lightbox\n                  \n          \n        \n                \"\n                data-description=\"\"\n                data-lightbox-theme=\"dark\"\n            ><br \/>\n              <span class=\"v6-visually-hidden\">View fullsize<\/span><\/p>\n<div\n              \n              \n              class=\"image-block-wrapper\"\n              data-animation-role=\"image\"\n              \n  data-animation-override\n\n          ><\/p>\n<div class=\"sqs-image-shape-container-element\n              \n          \n        \n              has-aspect-ratio\n            \" style=\"\n                position: relative;\n                \n                  padding-bottom:24.927953720092773%;\n                \n                overflow: hidden;-webkit-mask-image: -webkit-radial-gradient(white, black);\n              \"\n              ><\/p>\n<p>                  <img loading=\"lazy\" data-stretch=\"false\" src=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png\" data-image=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png\" data-image-dimensions=\"694x173\" data-image-focal-point=\"0.5,0.5\" alt=\"output2.png\" data-load=\"false\" elementtiming=\"system-image-block\" src=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png\" width=\"694\" height=\"173\" alt=\"\" sizes=\"auto, (max-width: 640px) 100vw, (max-width: 767px) 100vw, 100vw\" style=\"display:block;object-fit: cover; width: 100%; height: 100%; object-position: 50% 50%\" onload=\"this.classList.add(&quot;loaded&quot;)\" srcset=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png?format=100w 100w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png?format=300w 300w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png?format=500w 500w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png?format=750w 750w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png?format=1000w 1000w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png?format=1500w 1500w, https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523841121-5ED5YP2HP2GF2MAG1HRS\/output2.png?format=2500w 2500w\" loading=\"lazy\" decoding=\"async\" data-loader=\"sqs\"><\/p><\/div>\n<\/p><\/div>\n<p>            <\/button><\/p>\n<\/figure><\/div>\n<div class=\"sqs-html-content\">\n<p>That&#8217;s really it, you can explore things such as <strong>finally<\/strong>&nbsp;blocks that go after the catch block and happen no matter what the result of the code is, however the try\/catch concept is the foundation to it all and with this extremely simple tip you can properly handle nearly any command without having to guess and check to see if it produces a terminating error or not.&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p style=\"white-space: pre-wrap;\">Error handling is easily one of the most overlooked things about Powershell in my opinion, it seems like I see a ton of well written scripts with just improper error handling, but why? It&#8217;s actually not that hard of a concept, until you aren&#8217;t sure whether or not something produces a terminating error&#8230; Unless you know 1 extremely simple tip\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Properly using try\/catch to handle errors - Nathan Kasco - Blog<\/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:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Properly using try\/catch to handle errors - Nathan Kasco - Blog\" \/>\n<meta property=\"og:description\" content=\"Error handling is easily one of the most overlooked things about Powershell in my opinion, it seems like I see a ton of well written scripts with just improper error handling, but why? It&#039;s actually not that hard of a concept, until you aren&#039;t sure whether or not something produces a terminating error... Unless you know 1 extremely simple tip\u2026\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/\" \/>\n<meta property=\"og:site_name\" content=\"Nathan Kasco - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-19T11:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\" \/>\n<meta name=\"author\" content=\"Nate Kasco\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Bu5yGiraffe\" \/>\n<meta name=\"twitter:site\" content=\"@Bu5yGiraffe\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nate Kasco\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/\"},\"author\":{\"name\":\"Nate Kasco\",\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3\"},\"headline\":\"Properly using try\/catch to handle errors\",\"datePublished\":\"2018-05-19T11:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/\"},\"wordCount\":367,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3\"},\"image\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/\",\"url\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/\",\"name\":\"Properly using try\/catch to handle errors - Nathan Kasco - Blog\",\"isPartOf\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\",\"datePublished\":\"2018-05-19T11:00:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage\",\"url\":\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\",\"contentUrl\":\"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.nkasco.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Properly using try\/catch to handle errors\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/#website\",\"url\":\"https:\/\/blog.nkasco.com\/wordpress\/\",\"name\":\"Nathan Kasco - Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.nkasco.com\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3\",\"name\":\"Nate Kasco\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png\",\"url\":\"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png\",\"contentUrl\":\"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png\",\"width\":200,\"height\":200,\"caption\":\"Nate Kasco\"},\"logo\":{\"@id\":\"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png\"},\"sameAs\":[\"http:\/\/nkascocom.nk\/wordpress\",\"https:\/\/x.com\/Bu5yGiraffe\"],\"url\":\"https:\/\/blog.nkasco.com\/wordpress\/index.php\/author\/nate\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Properly using try\/catch to handle errors - Nathan Kasco - Blog","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:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/","og_locale":"en_US","og_type":"article","og_title":"Properly using try\/catch to handle errors - Nathan Kasco - Blog","og_description":"Error handling is easily one of the most overlooked things about Powershell in my opinion, it seems like I see a ton of well written scripts with just improper error handling, but why? It's actually not that hard of a concept, until you aren't sure whether or not something produces a terminating error... Unless you know 1 extremely simple tip\u2026","og_url":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/","og_site_name":"Nathan Kasco - Blog","article_published_time":"2018-05-19T11:00:00+00:00","og_image":[{"url":"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png","type":"","width":"","height":""}],"author":"Nate Kasco","twitter_card":"summary_large_image","twitter_creator":"@Bu5yGiraffe","twitter_site":"@Bu5yGiraffe","twitter_misc":{"Written by":"Nate Kasco","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#article","isPartOf":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/"},"author":{"name":"Nate Kasco","@id":"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3"},"headline":"Properly using try\/catch to handle errors","datePublished":"2018-05-19T11:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/"},"wordCount":367,"commentCount":0,"publisher":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3"},"image":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage"},"thumbnailUrl":"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/","url":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/","name":"Properly using try\/catch to handle errors - Nathan Kasco - Blog","isPartOf":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage"},"image":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage"},"thumbnailUrl":"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png","datePublished":"2018-05-19T11:00:00+00:00","breadcrumb":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#primaryimage","url":"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png","contentUrl":"https:\/\/images.squarespace-cdn.com\/content\/v1\/5ad54fd4cef37247634a91ca\/1526523803517-K4MQZLVTT38R3YPH4H0H\/output1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/2018\/05\/19\/2018-5-13-properly-using-trycatch-to-handle-errors\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.nkasco.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Properly using try\/catch to handle errors"}]},{"@type":"WebSite","@id":"https:\/\/blog.nkasco.com\/wordpress\/#website","url":"https:\/\/blog.nkasco.com\/wordpress\/","name":"Nathan Kasco - Blog","description":"","publisher":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.nkasco.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/blog.nkasco.com\/wordpress\/#\/schema\/person\/1dfd694a2ed094a43a37dc6882c65eb3","name":"Nate Kasco","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png","url":"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png","contentUrl":"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png","width":200,"height":200,"caption":"Nate Kasco"},"logo":{"@id":"https:\/\/blog.nkasco.com\/wordpress\/wp-content\/uploads\/2024\/03\/cropped-logo.png"},"sameAs":["http:\/\/nkascocom.nk\/wordpress","https:\/\/x.com\/Bu5yGiraffe"],"url":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/author\/nate\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":0,"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nkasco.com\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}