{"id":36249,"date":"2024-11-26T08:56:52","date_gmt":"2024-11-26T00:56:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/36249\/"},"modified":"2024-11-26T08:56:52","modified_gmt":"2024-11-26T00:56:52","slug":"%e4%bd%bf%e7%94%a8-exceptionhandler-%e5%85%a8%e5%b1%80%e5%bc%82%e5%b8%b8%e5%a4%84%e7%90%86%e6%97%b6%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88%e5%bc%82%e5%b8%b8%e6%9c%aa%e8%a2%ab-catch-%e6%8d%95%e8%8e%b7","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/36249\/","title":{"rendered":"\u4f7f\u7528 @ExceptionHandler \u5168\u5c40\u5f02\u5e38\u5904\u7406\u65f6\uff0c\u4e3a\u4ec0\u4e48\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173104184376366.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 @ExceptionHandler \u5168\u5c40\u5f02\u5e38\u5904\u7406\u65f6\uff0c\u4e3a\u4ec0\u4e48\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528 @ExceptionHandler \u5168\u5c40\u5f02\u5e38\u5904\u7406\u65f6\uff0c\u4e3a\u4ec0\u4e48\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7<\/strong><\/p>\n<p>\u5728\u5904\u7406\u5f02\u5e38\u65f6\uff0c\u4f7f\u7528 @ExcepionHandler \u5168\u5c40\u5f02\u5e38\u5904\u7406\u65f6\u53ef\u80fd\u9047\u5230\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u5177\u4f53\u539f\u56e0\u53ef\u80fd\u662f\u56e0\u4e3a try catch \u6240\u6355\u83b7\u7684\u5f02\u5e38\u7c7b\u578b\u4e0e\u5b9e\u9645\u629b\u51fa\u7684\u5f02\u5e38\u7c7b\u578b\u4e0d\u5339\u914d\u3002\u4f8b\u5982\uff0c\u4ee3\u7801\u4e2d\u4f7f\u7528 try catch \u6355\u83b7\u4e86 NullPointerException\uff0c\u4f46\u5b9e\u9645\u629b\u51fa\u7684\u662f FlowableException\u3002\u6b64\u65f6\uff0ctry catch \u5c06\u65e0\u6cd5\u6355\u83b7\u5230\u6b64\u5f02\u5e38\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u629b\u51fa\u7684\u5f02\u5e38\u7c7b\u578b\u8c03\u6574 try catch \u8bed\u53e5\u4e2d\u6355\u83b7\u7684\u5f02\u5e38\u7c7b\u578b\u3002\u540c\u65f6\u786e\u4fdd try catch \u6240\u5305\u56f4\u7684\u4ee3\u7801\u6bb5\u5305\u542b\u4e86\u629b\u51fa\u5f02\u5e38\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 @ExceptionHandler \u5168\u5c40\u5f02\u5e38\u5904\u7406\u65f6\uff0c\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7 \u5728\u5904\u7406\u5f02\u5e38\u65f6\uff0c\u4f7f\u7528 @ExcepionHandler \u5168\u5c40\u5f02\u5e38\u5904\u7406\u65f6\u53ef\u80fd\u9047\u5230\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7\u7684\u60c5\u51b5\u3002 \u5177\u4f53\u539f\u56e0\u53ef\u80fd\u662f\u56e0\u4e3a try catch \u6240\u6355\u83b7\u7684\u5f02\u5e38\u7c7b\u578b\u4e0e\u5b9e\u9645\u629b\u51fa\u7684\u5f02\u5e38\u7c7b\u578b\u4e0d\u5339\u914d\u3002\u4f8b\u5982\uff0c\u4ee3\u7801\u4e2d\u4f7f\u7528 try catch \u6355\u83b7\u4e86 NullPointerException\uff0c\u4f46\u5b9e\u9645\u629b\u51fa\u7684\u662f FlowableException\u3002\u6b64\u65f6\uff0ctry catch \u5c06\u65e0\u6cd5\u6355\u83b7\u5230\u6b64\u5f02\u5e38\u3002 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u629b\u51fa\u7684\u5f02\u5e38\u7c7b\u578b\u8c03\u6574 try catch \u8bed\u53e5\u4e2d\u6355\u83b7\u7684\u5f02\u5e38\u7c7b\u578b\u3002\u540c\u65f6\u786e\u4fdd try catch \u6240\u5305\u56f4\u7684\u4ee3\u7801\u6bb5\u5305\u542b\u4e86\u629b\u51fa\u5f02\u5e38\u7684\u4ee3\u7801\u3002 \u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 @ExceptionHandler \u5168\u5c40\u5f02\u5e38\u5904\u7406\u65f6\uff0c\u5f02\u5e38\u672a\u88ab catch \u6355\u83b7\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-36249","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=36249"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36249\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=36249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=36249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=36249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}