{"id":910191,"date":"2020-07-10T12:12:33","date_gmt":"2020-07-10T19:12:33","guid":{"rendered":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=910191"},"modified":"2020-07-10T12:12:33","modified_gmt":"2020-07-10T19:12:33","slug":"javascript-debugging-tips-part-iv-error-handling","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling","title":{"rendered":"JavaScript Debugging Tips Part IV &#8211; Error Handling"},"author":7451,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[22941],"tags":[96582,72381,38851,24921,27491],"industry":[],"product":[36831,36601],"class_list":["post-910191","blog","type-blog","status-publish","format-standard","hentry","category-mapping","tag-arcgis-api-for-javascript","tag-debugging","tag-developers","tag-javascript","tag-jsapi4","product-js-api-arcgis","product-developers"],"acf":{"short_description":"This blog post is the fourth in a series of JavaScript debugging tips and tricks to help you on your way.","flexible_content":[{"acf_fc_layout":"content","content":"<p>If you&#8217;re anything like me, you make mistakes. A lot of them. Fortunately, I work on a team full of super-sharp people who have enough patience to help me deal with my issues while they manage their own. But as I learn and grow, I want to take up less of their time, and figure out how to resolve my own minor crises.<\/p>\n<p>This blog post is the fourth in a series of JavaScript debugging tips and tricks to help you on your way. While earlier posts focused on browser debugging, this one will have an emphasis on using native JavaScript to handle errors with the 4x version of the <a href=\"https:\/\/developers.arcgis.com\/javascript\/\">ArcGIS API for JavaScript.<\/a> The next blog will focus on the error handling abilities of the API itself.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":913611,"id":913611,"title":"Nothing happened","filename":"nothing_happened.png","filesize":20979,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/nothing_happened","alt":"Nothing happened","author":"7451","description":"Nothing happened","caption":"","name":"nothing_happened","status":"inherit","uploaded_to":910191,"date":"2020-07-01 22:34:04","modified":"2020-07-01 22:34:18","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":336,"height":250,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","medium-width":336,"medium-height":250,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","medium_large-width":336,"medium_large-height":250,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","large-width":336,"large-height":250,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","1536x1536-width":336,"1536x1536-height":250,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","2048x2048-width":336,"2048x2048-height":250,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","card_image-width":336,"card_image-height":250,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/nothing_happened.png","wide_image-width":336,"wide_image-height":250}},"image_position":"left-center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<h3>Nothing happened<\/h3>\n<p>This is my most common issue. I write some code and run it in a browser, and either nothing happens or nothing changed. No bueno. So I go to the samples and <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/index.html?search=labeling\">search for a keyword<\/a> and then copy and paste part of the sample code from the sandbox, host it locally in my original app, and watch it work. Bueno. But I learned nothing.<\/p>\n<p>When this happens, cracking open the browser console will usually reveal what&#8217;s gone wrong. If it&#8217;s not there, then for sure there&#8217;s a request in the network tab that had an erroneous response. These are good ways to figure out what broke, but only after the fact. As <a href=\"https:\/\/en.wikipedia.org\/wiki\/Maureen_Howard\">Maureen Howard<\/a> said: <em>&#8220;Hindsight is common and bland as boiled potatoes.&#8221;<\/em><\/p>\n<p>We should really try to get in front of our potential potato problems. Let&#8217;s look at the app development process and see where we can make some improvements.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":913681,"id":913681,"title":"Error handling","filename":"error_handling.png","filesize":21353,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/error_handling","alt":"Error handling","author":"7451","description":"Error handling","caption":"","name":"error_handling","status":"inherit","uploaded_to":910191,"date":"2020-07-01 22:47:56","modified":"2020-07-01 22:48:16","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":336,"height":252,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","medium-width":336,"medium-height":252,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","medium_large-width":336,"medium_large-height":252,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","large-width":336,"large-height":252,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","1536x1536-width":336,"1536x1536-height":252,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","2048x2048-width":336,"2048x2048-height":252,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","card_image-width":336,"card_image-height":252,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/error_handling.png","wide_image-width":336,"wide_image-height":252}},"image_position":"left-center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<h3>JavaScript error handling<\/h3>\n<p>Like a trail of luminescent stones left out in the moonlight, adding proper error handling logic to your code can help guide you to where you want to go. Let&#8217;s look at an example.<\/p>\n<p>Say you want to create an app with some granular printing controls. If you look at the doc for <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-tasks-PrintTask.html#execute\">printTask.execute()<\/a>, you can see that the method takes two parameters; the first is required and the second is optional. You can also see that the method returns a promise, which when resolved returns a <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-tasks-PrintTask.html#PrintResponse\">PrintResponse<\/a> with one property.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":920531,"id":920531,"title":"printTask.execute()","filename":"PrintTaskMethodDetails.png","filesize":25014,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/printtaskmethoddetails","alt":"printTask.execute()","author":"7451","description":"printTask.execute()","caption":"","name":"printtaskmethoddetails","status":"inherit","uploaded_to":910191,"date":"2020-07-07 17:24:59","modified":"2020-07-07 17:25:21","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":991,"height":152,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails-213x152.png","thumbnail-width":213,"thumbnail-height":152,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails.png","medium-width":464,"medium-height":71,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails.png","medium_large-width":768,"medium_large-height":118,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails.png","large-width":991,"large-height":152,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails.png","1536x1536-width":991,"1536x1536-height":152,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails.png","2048x2048-width":991,"2048x2048-height":152,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails-826x127.png","card_image-width":826,"card_image-height":127,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/PrintTaskMethodDetails.png","wide_image-width":991,"wide_image-height":152}},"image_position":"center","orientation":"horizontal","hyperlink":"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-tasks-PrintTask.html#execute"},{"acf_fc_layout":"content","content":"<p>If you look at the code snippet for printTask.execute(), you see this line:<\/p>\n<p><code>printTask.execute(params).then(printResult, printError);<\/code><\/p>\n<p>This makes use of the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Promise\">promise<\/a> that is returned as the result of the printTask using a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Promise\/then\">.then() method<\/a> that calls the printResult() function if the promise resolves, or calls the printError() function if the promise fails. Here is a <a href=\"https:\/\/codepen.io\/noash\/pen\/gOPoxZj?editors=1001\">live app<\/a> that has two print buttons. One should pass, and one should fail.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":915851,"id":915851,"title":"PrintTask Pass\/Fail","filename":"print-task-pass-fail-app.png","filesize":195523,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/print-task-pass-fail-app","alt":"PrintTask Pass\/Fail","author":"7451","description":"PrintTask app","caption":"PrintTask app. Click the image to go to the live app.","name":"print-task-pass-fail-app","status":"inherit","uploaded_to":910191,"date":"2020-07-02 22:51:44","modified":"2020-07-02 22:52:53","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":1382,"height":700,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app.png","medium-width":464,"medium-height":235,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app.png","medium_large-width":768,"medium_large-height":389,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app.png","large-width":1382,"large-height":700,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app.png","1536x1536-width":1382,"1536x1536-height":700,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app.png","2048x2048-width":1382,"2048x2048-height":700,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app-826x418.png","card_image-width":826,"card_image-height":418,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/print-task-pass-fail-app.png","wide_image-width":1382,"wide_image-height":700}},"image_position":"center","orientation":"horizontal","hyperlink":"https:\/\/codepen.io\/noash\/pen\/gOPoxZj"},{"acf_fc_layout":"content","content":"<p>Open the console of the web browser, and you should see this message:<\/p>\n<p><code>Something broke: TypeError: Cannot read property 'spatialReference' of null<\/code><\/p>\n<p>Sure enough, the spatial reference is null because I forgot to define the view when I constructed the second print task function. But if I did not have that simple printError() function, it would be far less obvious what the issue was.<\/p>\n<p>Now that&#8217;s a good way to handle errors with native JavaScript promises, which the ArcGIS API for JavaScript <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/guide\/4.15\/index.html#return-native-promises\">returns by default<\/a> since version 4.15. Let&#8217;s look at another way to handle errors.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":921041,"id":921041,"title":"JavaScript can do it","filename":"JS_can_Do_it.png","filesize":22829,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/js_can_do_it","alt":"JavaScript can do it","author":"7451","description":"JavaScript can do it","caption":"","name":"js_can_do_it","status":"inherit","uploaded_to":910191,"date":"2020-07-07 18:23:12","modified":"2020-07-07 18:23:25","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":335,"height":252,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","medium-width":335,"medium-height":252,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","medium_large-width":335,"medium_large-height":252,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","large-width":335,"large-height":252,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","1536x1536-width":335,"1536x1536-height":252,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","2048x2048-width":335,"2048x2048-height":252,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","card_image-width":335,"card_image-height":252,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/JS_can_Do_it.png","wide_image-width":335,"wide_image-height":252}},"image_position":"left-center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<p>Another option is to use <a href=\"https:\/\/www.w3schools.com\/js\/js_errors.asp\">try and catch<\/a> statements. This is a good way to handle new and\/or important functionality in your app. So if you&#8217;re adding something new and just testing it out, this is a good option to try it out. Or if there is functionality that you want to actively monitor, this is a good option to catch any potential issues and handle them appropriately.<\/p>\n<p>Here is an example of what a try and catch statement looks like:<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":929191,"id":929191,"title":"Try and Catch syntax","filename":"try-catch-syntax.png","filesize":12791,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/try-catch-syntax","alt":"Try and Catch syntax","author":"7451","description":"Try and Catch syntax","caption":"","name":"try-catch-syntax","status":"inherit","uploaded_to":910191,"date":"2020-07-09 20:58:13","modified":"2020-07-09 20:58:27","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":633,"height":277,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","medium-width":464,"medium-height":203,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","medium_large-width":633,"medium_large-height":277,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","large-width":633,"large-height":277,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","1536x1536-width":633,"1536x1536-height":277,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","2048x2048-width":633,"2048x2048-height":277,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","card_image-width":633,"card_image-height":277,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try-catch-syntax.png","wide_image-width":633,"wide_image-height":277}},"image_position":"left-center","orientation":"horizontal","hyperlink":"https:\/\/www.w3schools.com\/js\/js_errors.asp"},{"acf_fc_layout":"content","content":"<p>This time, let&#8217;s wrap our important functionality in the try statement. Then we&#8217;ll add some logic to the catch statement so that the app doesn&#8217;t crash if the try statement fails. This is a better end-user experience (e.g. an experience versus a blank screen).<\/p>\n<p>This app makes use of the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-layers-OGCFeatureLayer.html\">OGCFeatureLayer<\/a>, which is new at version 4.16. The functionality we want to monitor is the ability to switch between a 2D MapView and a 3D SceneView with the click of a button. As an aside, we were able to match the exact purple color between the CSS, the button, and the label halos by using the <a href=\"https:\/\/developers.google.com\/web\/tools\/chrome-devtools\/css\/reference\">Color Picker in Chrome DevTools<\/a>.<\/p>\n<p>The try statement starts at line 153. We <em>try<\/em> to set the viewpoint, container, and activeView properties to match the view that the end-user switched to. Now without this try\/catch statement, if this part of the app failed, the app would crash, the screen would be blank, and the console would be full of helpful but slightly angry error messages. A better way is to add the try\/catch statement, so that if the try part fails, the catch part keeps the app alive. In this app, we assign the above property values to the last known working values, then log a message in the console.<\/p>\n<details>\n<summary>Expand to view the code for try\/catch<\/summary>\n<pre><code style=\"display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; -webkit-text-size-adjust: none;\"><span style=\"color: #333; font-weight: bold;\">if<\/span><span style=\"color: #333333;\"> (is3D) {\r\n<\/span>   <span style=\"color: #333; font-weight: bold;\">try<\/span><span style=\"color: #333333;\"> {\r\n<\/span>      <span style=\"color: #0086b3;\">console<\/span><span style=\"color: #333333;\">.log(<\/span><span style=\"color: #d14;\">\"Switching to 2D\"<\/span><span style=\"color: #333333;\">);\r\n      appConfig.mapView.viewpoint = appConfig.container;\r\n      appConfig.mapView.container = appConfig.mapView;\r\n      appConfig.activeView = activeViewpoint;\r\n      switchButton.value = <\/span><span style=\"color: #d14;\">\"3D\"<\/span><span style=\"color: #333333;\">;\r\n      } <\/span><span style=\"color: #333; font-weight: bold;\">catch<\/span><span style=\"color: #333333;\"> {\r\n<\/span>         <span style=\"color: #0086b3;\">console<\/span><span style=\"color: #333333;\">.log(<\/span><span style=\"color: #d14;\">\"Problem switching to 2D. Remaining in 3D.\"<\/span><span style=\"color: #333333;\">);\r\n         appConfig.sceneView.viewpoint = activeViewpoint;\r\n         appConfig.sceneView.container = appConfig.container;\r\n         appConfig.activeView = appConfig.sceneView;\r\n         switchButton.value = <\/span><span style=\"color: #d14;\">\"2D\"<\/span><span style=\"color: #333333;\">;\r\n      }\r\n} <\/span><span style=\"color: #333; font-weight: bold;\">else<\/span><span style=\"color: #333333;\"> {\r\n<\/span><span style=\"color: #333; font-weight: bold;\">   try<\/span><span style=\"color: #333333;\"> {\r\n<\/span>      <span style=\"color: #0086b3;\">console<\/span><span style=\"color: #333333;\">.log(<\/span><span style=\"color: #d14;\">\"Switching to 3D\"<\/span><span style=\"color: #333333;\">);\r\n      appConfig.sceneView.viewpoint = activeViewpoint;\r\n      appConfig.sceneView.container = appConfig.container;\r\n      appConfig.activeView = appConfig.sceneView;\r\n      switchButton.value = <\/span><span style=\"color: #d14;\">\"2D\"<\/span><span style=\"color: #333333;\">;\r\n      } <\/span><span style=\"color: #333; font-weight: bold;\">catch<\/span><span style=\"color: #333333;\"> {\r\n<\/span>         <span style=\"color: #0086b3;\">console<\/span><span style=\"color: #333333;\">.log(<\/span><span style=\"color: #d14;\">\"Problem switching to 3D. Remaining in 2D.\"<\/span><span style=\"color: #333333;\">);\r\n         appConfig.mapView.viewpoint = activeViewpoint;\r\n         appConfig.mapView.container = appConfig.container;\r\n         appConfig.activeView = appConfig.mapView;\r\n         switchButton.value = <\/span><span style=\"color: #d14;\">\"3D\"<\/span><span style=\"color: #333333;\">;\r\n      }\r\n}\r\n<\/span><\/code><\/pre>\n<\/details>\n"},{"acf_fc_layout":"content","content":"<p>The code snippet above shows how the app below works. Click on the <code>3D<\/code> or <code>2D<\/code> button in the upper-left corner to run the app and run into issues: <a href=\"https:\/\/codepen.io\/noash\/pen\/GRodabG\">try\/catch OGCFeatureLayer app<\/a>.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":929101,"id":929101,"title":"try\/catch OGCFeatureLayer","filename":"OGCFeatureLayer_App.png","filesize":85155,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/ogcfeaturelayer_app","alt":"try\/catch OGCFeatureLayer","author":"7451","description":"try\/catch OGCFeatureLayer","caption":"","name":"ogcfeaturelayer_app","status":"inherit","uploaded_to":910191,"date":"2020-07-09 20:47:17","modified":"2020-07-09 20:47:37","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":1055,"height":549,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App.png","medium-width":464,"medium-height":241,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App.png","medium_large-width":768,"medium_large-height":400,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App.png","large-width":1055,"large-height":549,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App.png","1536x1536-width":1055,"1536x1536-height":549,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App.png","2048x2048-width":1055,"2048x2048-height":549,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App-826x430.png","card_image-width":826,"card_image-height":430,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/OGCFeatureLayer_App.png","wide_image-width":1055,"wide_image-height":549}},"image_position":"center","orientation":"horizontal","hyperlink":"https:\/\/codepen.io\/noash\/pen\/GRodabG"},{"acf_fc_layout":"content","content":"<p>Another good try and catch example from our SDK: <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/sandbox\/index.html?sample=layers-integratedmeshlayer-modification\">Sample &#8211; IntegratedMeshLayer modification<\/a>. The logic starts at line 249:<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":922201,"id":922201,"title":"try and catch snippet","filename":"try_catch_snippet.png","filesize":23415,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/try_catch_snippet","alt":"try and catch snippet","author":"7451","description":"try and catch snippet","caption":"","name":"try_catch_snippet","status":"inherit","uploaded_to":910191,"date":"2020-07-07 21:37:49","modified":"2020-07-07 21:38:01","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":602,"height":246,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","medium-width":464,"medium-height":190,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","medium_large-width":602,"medium_large-height":246,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","large-width":602,"large-height":246,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","1536x1536-width":602,"1536x1536-height":246,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","2048x2048-width":602,"2048x2048-height":246,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","card_image-width":602,"card_image-height":246,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/try_catch_snippet.png","wide_image-width":602,"wide_image-height":246}},"image_position":"left-center","orientation":"horizontal","hyperlink":"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/sandbox\/index.html?sample=layers-integratedmeshlayer-modification"},{"acf_fc_layout":"content","content":"<p>Fun, right? And practical.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":913621,"id":913621,"title":"Additional resources","filename":"additional_resources.png","filesize":24659,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\/additional_resources","alt":"Additional resources","author":"7451","description":"Additional resources","caption":"","name":"additional_resources","status":"inherit","uploaded_to":910191,"date":"2020-07-01 22:34:31","modified":"2020-07-01 22:34:45","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":336,"height":252,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","medium-width":336,"medium-height":252,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","medium_large-width":336,"medium_large-height":252,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","large-width":336,"large-height":252,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","1536x1536-width":336,"1536x1536-height":252,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","2048x2048-width":336,"2048x2048-height":252,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","card_image-width":336,"card_image-height":252,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/07\/additional_resources.png","wide_image-width":336,"wide_image-height":252}},"image_position":"left-center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<h3>Additional Resources<\/h3>\n<p>Want more? Me too. Here are some links to additional resources, and feel free to leave a comment below to share your own debugging resources.<\/p>\n<p>Past blogs in the series:<\/p>\n<ul>\n<li><strong><a class=\"jive-link-blog-small\" href=\"https:\/\/community.esri.com\/groups\/technical-support\/blog\/2014\/05\/06\/javascript-debugging-tips-part-i-google-chrome-and-the-network-tab-2\" data-containerid=\"1752\" data-containertype=\"37\" data-objectid=\"58664\" data-objecttype=\"38\">JavaScript Debugging Tips Part I &#8211; Google Chrome and the Network Tab<\/a><\/strong><\/li>\n<li><strong><a class=\"jive-link-blog-small\" href=\"https:\/\/community.esri.com\/groups\/technical-support\/blog\/2017\/01\/24\/javascript-debugging-tips-part-ii-google-chrome-and-the-console-tab\" data-containerid=\"1752\" data-containertype=\"37\" data-objectid=\"58736\" data-objecttype=\"38\">JavaScript Debugging Tips Part II &#8211; Google Chrome and the Console Tab<\/a><\/strong><\/li>\n<li><strong><a href=\"https:\/\/community.esri.com\/groups\/technical-support\/blog\/2017\/06\/14\/javascript-debugging-tips-part-iii-advanced-google-chrome-developer-tools-tips\">JavaScript Debugging Tips Part III &#8211; Advanced Google Chrome Developer Tools<\/a><\/strong><\/li>\n<\/ul>\n<p>Helpful videos:<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=CskPhPbXv58\">Webinar: Tips and Tricks for Developing and Debugging Apps (2020)<\/a><\/strong><\/li>\n<li><strong><a href=\"https:\/\/www.esri.com\/videos\/watch?videoid=o30MBicJmNo&amp;title=arcgis-api-for-javascript-tips-and-tricks-for-developing-and-debugging-apps\">ArcGIS API for JavaScript: Tips and Tricks for Developing and Debugging Apps (2019)<\/a><\/strong><\/li>\n<\/ul>\n<p>Useful doc:<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Promise\"><b>JavaScript Promise<\/b><\/a><\/li>\n<li><strong><a href=\"https:\/\/eloquentjavascript.net\/08_error.html\">Eloquent JavaScript &#8211; Bugs and Errors<\/a><\/strong><\/li>\n<li><strong><a href=\"https:\/\/www.w3schools.com\/js\/js_errors.asp\">JavaScript Errors &#8211; Throw and Try to Catch<\/a><\/strong><\/li>\n<\/ul>\n<p>Images:<\/p>\n<ul>\n<li>The comic-style images in this blog were generated using <a href=\"https:\/\/github.com\/OfficeDev\/microsoft-teams-stickers-app\">Microsoft Teams Stickers<\/a>.<\/li>\n<\/ul>\n"},{"acf_fc_layout":"content","content":"<p>Stay tuned till next time, when we&#8217;ll look using the ArcGIS API for JavaScript for error handling, instead of just native JavaScript. Happy debugging!<\/p>\n"}],"authors":[{"ID":7451,"user_firstname":"Noah","user_lastname":"Sager","nickname":"Noah Sager","user_nicename":"noah-sager","display_name":"Noah Sager","user_email":"NSager@esri.com","user_url":"https:\/\/www.noahsager.net\/","user_registered":"2018-03-21 18:21:19","user_description":"Passionate about JavaScript, maps, and writing (not necessarily in that order). Big fan of squirrels. Journeyman mapper of Utility Lines and Public Restrooms. Product Engineer on the ArcGIS API for JavaScript team. In Noah\u2019s spare time, he also enjoys parenting.","user_avatar":"<img alt='' src='https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&#038;d=blank&#038;r=g' srcset='https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=192&#038;d=blank&#038;r=g 2x' class='avatar avatar-96 photo' height='96' width='96' loading='lazy' decoding='async'\/>"}],"related_articles":[{"ID":861861,"post_author":"4271","post_date":"2020-07-09 11:48:26","post_date_gmt":"2020-07-09 18:48:26","post_content":"","post_title":"What's new in the ArcGIS API for JavaScript (July 2020)","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"whats-new-in-the-arcgis-api-for-javascript-july-2020","to_ping":"","pinged":"","post_modified":"2020-07-10 11:56:53","post_modified_gmt":"2020-07-10 18:56:53","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=861861","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"},{"ID":827321,"post_author":"4271","post_date":"2020-04-24 11:36:45","post_date_gmt":"2020-04-24 18:36:45","post_content":"","post_title":"DevSummit 2020 \u2013 ArcGIS API for JavaScript Recordings Available!","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"arcgis-api-for-javascript-devsummit-2020-videos-available","to_ping":"","pinged":"","post_modified":"2020-04-24 12:22:51","post_modified_gmt":"2020-04-24 19:22:51","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=827321","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"},{"ID":889091,"post_author":"3801","post_date":"2020-07-02 10:20:22","post_date_gmt":"2020-07-02 17:20:22","post_content":"","post_title":"Web Developers Guide to the 2020 Esri Users Conference","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"web-developers-guide-to-the-2020-esri-users-conference","to_ping":"","pinged":"","post_modified":"2020-07-14 08:57:52","post_modified_gmt":"2020-07-14 15:57:52","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=889091","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"}],"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/06\/debugging.jpg","wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/06\/deblug_cover_1-copy.png"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript Debugging Tips Part IV - Error Handling<\/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:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Debugging Tips Part IV - Error Handling\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\"},\"author\":{\"name\":\"Noah Sager\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/31358cd525c152696fcd5fe96f49e068\"},\"headline\":\"JavaScript Debugging Tips Part IV &#8211; Error Handling\",\"datePublished\":\"2020-07-10T19:12:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\"},\"wordCount\":8,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"ArcGIS API for JavaScript\",\"debugging\",\"Developers\",\"JavaScript\",\"jsapi4\"],\"articleSection\":[\"Mapping\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\",\"name\":\"JavaScript Debugging Tips Part IV - Error Handling\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2020-07-10T19:12:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Debugging Tips Part IV &#8211; Error Handling\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/31358cd525c152696fcd5fe96f49e068\",\"name\":\"Noah Sager\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g\",\"caption\":\"Noah Sager\"},\"description\":\"Passionate about JavaScript, maps, and writing (not necessarily in that order). Big fan of squirrels. Journeyman mapper of Utility Lines and Public Restrooms. Product Engineer on the ArcGIS API for JavaScript team. In Noah\u2019s spare time, he also enjoys parenting.\",\"sameAs\":[\"https:\/\/www.noahsager.net\/\",\"https:\/\/www.linkedin.com\/in\/noah-sager\",\"https:\/\/x.com\/noashx\"],\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/author\/noah-sager\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JavaScript Debugging Tips Part IV - Error Handling","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:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling","og_locale":"en_US","og_type":"article","og_title":"JavaScript Debugging Tips Part IV - Error Handling","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","twitter_card":"summary_large_image","twitter_site":"@ESRI","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling"},"author":{"name":"Noah Sager","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/31358cd525c152696fcd5fe96f49e068"},"headline":"JavaScript Debugging Tips Part IV &#8211; Error Handling","datePublished":"2020-07-10T19:12:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling"},"wordCount":8,"commentCount":0,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["ArcGIS API for JavaScript","debugging","Developers","JavaScript","jsapi4"],"articleSection":["Mapping"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling","name":"JavaScript Debugging Tips Part IV - Error Handling","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2020-07-10T19:12:33+00:00","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/mapping\/javascript-debugging-tips-part-iv-error-handling#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript Debugging Tips Part IV &#8211; Error Handling"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/31358cd525c152696fcd5fe96f49e068","name":"Noah Sager","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g","caption":"Noah Sager"},"description":"Passionate about JavaScript, maps, and writing (not necessarily in that order). Big fan of squirrels. Journeyman mapper of Utility Lines and Public Restrooms. Product Engineer on the ArcGIS API for JavaScript team. In Noah\u2019s spare time, he also enjoys parenting.","sameAs":["https:\/\/www.noahsager.net\/","https:\/\/www.linkedin.com\/in\/noah-sager","https:\/\/x.com\/noashx"],"url":"https:\/\/www.esri.com\/arcgis-blog\/author\/noah-sager"}]}},"text_date":"July 10, 2020","author_name":"Noah Sager","author_page":"https:\/\/www.esri.com\/arcgis-blog\/author\/noah-sager","custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2020\/06\/deblug_cover_1-copy.png","primary_product":"ArcGIS Maps SDK for JavaScript","tag_data":[{"term_id":96582,"name":"ArcGIS API for JavaScript","slug":"arcgis-api-for-javascript","term_group":0,"term_taxonomy_id":96582,"taxonomy":"post_tag","description":"","parent":0,"count":58,"filter":"raw"},{"term_id":72381,"name":"debugging","slug":"debugging","term_group":0,"term_taxonomy_id":72381,"taxonomy":"post_tag","description":"","parent":0,"count":3,"filter":"raw"},{"term_id":38851,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":38851,"taxonomy":"post_tag","description":"","parent":0,"count":79,"filter":"raw"},{"term_id":24921,"name":"JavaScript","slug":"javascript","term_group":0,"term_taxonomy_id":24921,"taxonomy":"post_tag","description":"","parent":0,"count":151,"filter":"raw"},{"term_id":27491,"name":"jsapi4","slug":"jsapi4","term_group":0,"term_taxonomy_id":27491,"taxonomy":"post_tag","description":"","parent":0,"count":111,"filter":"raw"}],"category_data":[{"term_id":22941,"name":"Mapping","slug":"mapping","term_group":0,"term_taxonomy_id":22941,"taxonomy":"category","description":"","parent":0,"count":2706,"filter":"raw"}],"product_data":[{"term_id":36831,"name":"ArcGIS Maps SDK for JavaScript","slug":"js-api-arcgis","term_group":0,"term_taxonomy_id":36831,"taxonomy":"product","description":"","parent":36601,"count":364,"filter":"raw"},{"term_id":36601,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":36601,"taxonomy":"product","description":"","parent":0,"count":767,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=js-api-arcgis","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/910191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/7451"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=910191"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/910191\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=910191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=910191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=910191"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=910191"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=910191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}