{"id":2018,"date":"2022-07-16T13:36:05","date_gmt":"2022-07-16T04:36:05","guid":{"rendered":"http:\/\/www.agile-software.site\/?p=2018"},"modified":"2022-07-17T08:22:10","modified_gmt":"2022-07-16T23:22:10","slug":"trycatch","status":"publish","type":"post","link":"https:\/\/agile-software.net\/?p=2018","title":{"rendered":"try~catch"},"content":{"rendered":"\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u969b\u306b\u30a8\u30e9\u30fc\uff08\u4f8b\u5916\uff09\u304c\u8d77\u3053\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u901a\u5e38\u306f\u30a8\u30e9\u30fc\u304c\u8d77\u3053\u3063\u305f\u969b\u3001\u305d\u3053\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u6b62\u307e\u308a\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u5b9f\u969b\u306e\u5834\u9762\u3067\u306f\u30a8\u30e9\u30fc\u304c\u8d77\u3053\u3063\u3066\u3082\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u6b62\u307e\u3063\u3066\u6b32\u3057\u304f\u306a\u3044\u5834\u5408\u3082\u3042\u308a\u307e\u3059\u3002\u305d\u3093\u306a\u6642\u306b\u4f7f\u3048\u308b\u306e\u304c<strong>try~catch\u6587<\/strong>\u3067\u3059\u3002<\/p>\n\n\n\n<p>try~catch\u6587\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u4f8b\u5916\u51e6\u7406\u3092\u8a18\u8ff0\u3067\u304d\u307e\u3059\u3002 \u4f8b\u5916\u51e6\u7406\u3068\u306f\u3001\u4e88\u671f\u3057\u3066\u3044\u306a\u3044\u7570\u5e38\u306b\u3088\u308a\u30a8\u30e9\u30fc\uff08\u4f8b\u5916\uff09\u304c\u767a\u751f\u3059\u308b\u5834\u9762\u3067\u610f\u56f3\u7684\u306b\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3059\u308b\u3053\u3068\u3067\u3059\u3002 \u4f8b\u5916\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u3001\u4f8b\u5916\u306e\u767a\u751f\u5834\u9762\u3067\u3082\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30b9\u30c8\u30c3\u30d7\u3055\u305b\u305a\u306b\u5225\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>try{\n    \/\/\u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u51e6\u7406\n}catch(e){\n    \/\/\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306e\u51e6\u7406\n}<\/code><\/pre><\/div>\n\n\n\n<p>try\u30d6\u30ed\u30c3\u30af\u5185\u306b\u4f8b\u5916\u306e\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u3001\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306b\u306fcatch\u30d6\u30ed\u30c3\u30af\u5185\u306e\u51e6\u7406\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002 catch\u30d6\u30ed\u30c3\u30af\u306e\u5f15\u6570\u306b\u306fError\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u6e21\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>try {\n    var greeting = &quot;\u3053\u3093\u306b\u3061\u306f\u3001&quot; + name + &quot;\u3067\u3059\u3002&quot;;\n    console.log( greeting );\n} catch(e) {\n    console.log( e.message );\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306e\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>name is not defined<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u5909\u6570name\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u901a\u5e38\u306f\u305d\u3053\u3067\u51e6\u7406\u304c\u7d42\u4e86\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001try~catch\u6587\u3092\u8a18\u8ff0\u3057\u3066\u3044\u308b\u3053\u3068\u3067catch\u30d6\u30ed\u30c3\u30af\u5185\u306e\u51e6\u7406\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002Error\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306emessage\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3046\u3068\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u969b\u306b\u30a8\u30e9\u30fc\uff08\u4f8b\u5916\uff09\u304c\u8d77\u3053\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u901a\u5e38\u306f\u30a8\u30e9\u30fc\u304c\u8d77\u3053\u3063\u305f\u969b\u3001\u305d\u3053\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u6b62\u307e\u308a\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u5b9f\u969b\u306e\u5834\u9762\u3067\u306f\u30a8\u30e9\u30fc\u304c\u8d77\u3053\u3063\u3066\u3082\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u6b62\u307e\u3063\u3066\u6b32\u3057\u304f\u306a\u3044\u5834\u5408\u3082\u3042\u308a\u307e\u3059\u3002\u305d\u3093\u306a\u6642\u306b\u4f7f\u3048\u308b<\/p>\n","protected":false},"author":1,"featured_media":2070,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"","_jin_last_featured_id":0,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-2018","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2018"}],"version-history":[{"count":1,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2018\/revisions"}],"predecessor-version":[{"id":2019,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2018\/revisions\/2019"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/media\/2070"}],"wp:attachment":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}