{"id":1423,"date":"2005-04-11T08:43:13","date_gmt":"2005-04-11T08:43:13","guid":{"rendered":"http:\/\/dev.jblove.net\/?p=1423"},"modified":"2005-04-11T08:43:13","modified_gmt":"2005-04-11T08:43:13","slug":"try-catch-js","status":"publish","type":"post","link":"https:\/\/jblove.net\/?p=1423","title":{"rendered":"try catch?? js ???"},"content":{"rendered":"<p>\uc1a1\ud6a8\uc9c4<\/p>\n<p>php5 \uc5d0 Exception \uc774\ub77c\ub294 try catch \uad6c\ubb38\uc774 \uc788\uc2b5\ub2c8\ub2e4.<br \/>\n\ud558\uc9c0\ub9cc \ub2e8\uc21c\ud788 try { } catch(e) { } \ub85c \uc0ac\uc6a9\ud560 \uc218\uac00 \uc5c6\ub124\uc694.<br \/>\n\ud074\ub798\uc2a4\ub97c \ub9cc\ub4e4\uc5b4\uc11c catch \ucabd\uc73c\ub85c throw \ud574\uc57c \ud558\ub294\uac83 \uac19\uad70\uc694.<br \/>\n\uc2e4\uc81c\uc801\uc778 &#8216;\uac10\uc9c0&#8217; \uae30\ub2a5\uc744 \ubabb\ud558\ub294\uac83 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uadf8\ub798\uc11c &#8216;\uac10\uc9c0&#8217;\uac00 \uac00\ub2a5\ud55c \ud568\uc218\ub97c \uc81c\uc791\ud588\uc2b5\ub2c8\ub2e4.<\/p>\n<p>include &#8216;debug.inc&#8217;;<br \/>\nSHJTry([\uac10\uc9c0\uc5d0\ub7ec\ub808\ubca8]);<br \/>\n\ucf54\ub4dc<br \/>\nif(false !== ($err = SHJCatch())) {<br \/>\n\uc5d0\ub7ec\uc2dc \ucf54\ub4dc<br \/>\n}<\/p>\n<p>\ub85c \uc0ac\uc6a9\ud558\uba74 \ub429\ub2c8\ub2e4.<\/p>\n<p>debug.inc<br \/>\n<?php<br \/>\n\/* Debug *\/<br \/>\nif(!isset($_DEBUG)) {<br \/>\n    $_DEBUG = false;<br \/>\n}<\/p>\n<p>$_TRYCATCH = false;<br \/>\n$_ERROR = false;<\/p>\n<p>function SHJErrorHandler($errno, $errstr, $errfile, $errline)<br \/>\n{<br \/>\n    global $_DEBUG, $_TRYCATCH, $_ERROR;<br \/>\n    $errname = array(E_ERROR => &#8216;ERROR&#8217;, E_WARNING => &#8216;WARNING&#8217;, E_NOTICE => &#8216;NOTICE&#8217;);<\/p>\n<p>    switch($errno) {<br \/>\n    case E_ERROR:<br \/>\n    case E_WARNING:<br \/>\n        if($errstr == &#8216;Division by zero&#8217;) {<br \/>\n            break;<br \/>\n        }<br \/>\n    case E_NOTICE:<br \/>\n        if($_TRYCATCH &#038; $errno) {<br \/>\n            $_ERROR[&#8216;no&#8217;] = $errno;<br \/>\n            $_ERROR[&#8216;str&#8217;] = $errstr;<br \/>\n            $_TRYCATCH = false;<br \/>\n        } else {<br \/>\n            echo &#8220;<xmp><br \/>\n&#8220;;<br \/>\n            echo $errname[$errno].&#8217; : &#8216;.$errstr.&#8217; : &#8216;.$errfile.&#8217; : &#8216;.$errline.&#8221;<br \/>\n&#8220;;<br \/>\n            if($_DEBUG) {<br \/>\n                print_r(debug_backtrace());<br \/>\n            }<br \/>\n            echo &#8220;<br \/>\n<\/xmp>&#8220;;<br \/>\n            if($_DEBUG) {<br \/>\n                exit;<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>function SHJTry($error_level = E_ALL)<br \/>\n{<br \/>\n    global $_TRYCATCH;<br \/>\n    $_TRYCATCH = $error_level;<br \/>\n}<\/p>\n<p>function SHJCatch()<br \/>\n{<br \/>\n    global $_TRYCATCH, $_ERROR;<\/p>\n<p>    $_TRYCATCH = false;<\/p>\n<p>    if(false !== $_ERROR) {<br \/>\n        $err = $_ERROR;<br \/>\n        $_ERROR = false;<br \/>\n        return $err;<br \/>\n    }<\/p>\n<p>    return false;<br \/>\n}<\/p>\n<p>error_reporting(E_ALL);<br \/>\nset_error_handler(&#8216;SHJErrorHandler&#8217;);<\/p>\n<p>?><\/p>\n<p>test.php<br \/>\n<?php\n\n\n$_DEBUG = true;<br \/>\ninclude_once &#8216;func.inc&#8217;;<br \/>\ninclude_once &#8220;debug.inc&#8221;;<\/p>\n<p>SHJTry();<br \/>\n$a = $b;<br \/>\nif(false !== ($err = SHJCatch())) {<br \/>\n    echo &#8216;$a = $b \uac00 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.<br \/>&#8216;;<br \/>\n    $b = &#8216;a&#8217;;<br \/>\n    $a = $b;<br \/>\n    echo &#8216;$b \uc5d0 a \ub97c \ub123\uace0 $a \uc5d0 \ub123\uc5c8\uc2b5\ub2c8\ub2e4.<br \/>&#8216;;<br \/>\n}<\/p>\n<p>SHJTry();<br \/>\n$a = $b;<br \/>\nif(false !== ($err = SHJCatch())) {<br \/>\n    echo &#8216;$a = $b \uac00 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.<br \/>&#8216;;<br \/>\n    $b = &#8216;b&#8217;;<br \/>\n    $a = $b;<br \/>\n    echo &#8216;$b \uc5d0 b \ub97c \ub123\uace0 $a \uc5d0 \ub123\uc5c8\uc2b5\ub2c8\ub2e4.<br \/>&#8216;;<br \/>\n}<\/p>\n<p>$a = $c;<\/p>\n<p>?><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc1a1\ud6a8\uc9c4 php5 \uc5d0 Exception \uc774\ub77c\ub294 try catch \uad6c\ubb38\uc774 \uc788\uc2b5\ub2c8\ub2e4. \ud558\uc9c0\ub9cc \ub2e8\uc21c\ud788 try { } catch(e) { } \ub85c \uc0ac\uc6a9\ud560 \uc218\uac00 \uc5c6\ub124\uc694. \ud074\ub798\uc2a4\ub97c \ub9cc\ub4e4\uc5b4\uc11c catch \ucabd\uc73c\ub85c throw \ud574\uc57c \ud558\ub294\uac83 \uac19\uad70\uc694. \uc2e4\uc81c\uc801\uc778 &#8216;\uac10\uc9c0&#8217; \uae30\ub2a5\uc744 \ubabb\ud558\ub294\uac83 \uac19\uc2b5\ub2c8\ub2e4. \uadf8\ub798\uc11c &#8216;\uac10\uc9c0&#8217;\uac00 \uac00\ub2a5\ud55c \ud568\uc218\ub97c \uc81c\uc791\ud588\uc2b5\ub2c8\ub2e4. include &#8216;debug.inc&#8217;; SHJTry([\uac10\uc9c0\uc5d0\ub7ec\ub808\ubca8]); \ucf54\ub4dc if(false !== ($err = SHJCatch())) { \uc5d0\ub7ec\uc2dc \ucf54\ub4dc } \ub85c \uc0ac\uc6a9\ud558\uba74 \ub429\ub2c8\ub2e4. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[51],"tags":[],"class_list":["post-1423","post","type-post","status-publish","format-standard","hentry","category-papa-php"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts\/1423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1423"}],"version-history":[{"count":0,"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts\/1423\/revisions"}],"wp:attachment":[{"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}