{"id":35,"date":"2016-02-10T16:30:58","date_gmt":"2016-02-10T16:30:58","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=35"},"modified":"2022-02-17T06:24:15","modified_gmt":"2022-02-17T06:24:15","slug":"using-error-catching","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/try-error-catching\/using-error-catching","title":{"rendered":"Using Error Catching"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Typical Try Catch<br><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\ttry\n\t{\n\t}\n\tcatch (Exception)\n\t{\n\t}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\ttry\n\t{\n\t}\n\tcatch (Exception err)\n\t{\n\t\tMessageBox.Show(\"An error occured:\\n\" + err, \"Error\", MessageBoxButtons.OK, MessageBoxIcon.Information);\n\t}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\ttry\n\t{\n\t}\n\tcatch (Exception ex)\n\t{\n\t\tSystem.Diagnostics.Debug.WriteLine(\"ERROR: \" + ex.Message);\n\t}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Throw<\/h4>\n\n\n\n<p>You can use throw in a try block to cause execution to jump out to the catch block, or in a class to cause the calling functions error handler to be invoked.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tthrow new System.InvalidOperationException(\"My error message\");<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Typical Try Catch Throw You can use throw in a try block to cause execution to jump out to the catch block, or in a class to cause the calling functions error handler to be invoked.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-try-error-catching"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":386,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/35\/revisions\/386"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}