{"id":951,"date":"2026-04-23T09:53:04","date_gmt":"2026-04-23T00:53:04","guid":{"rendered":"https:\/\/csharp.ihavenomoney.co.kr\/?p=951"},"modified":"2026-04-23T09:54:05","modified_gmt":"2026-04-23T00:54:05","slug":"%ec%98%88%ec%99%b8-%ec%b2%98%eb%a6%ac-%eb%a9%94%ec%8b%9c%ec%a7%80-%ec%83%81%ec%84%b8","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=951","title":{"rendered":"\uc608\uc678 \ucc98\ub9ac \uba54\uc2dc\uc9c0 \uc0c1\uc138"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\uc608\uc81c1<\/h2>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \">atch (Exception ex)\n{\n    string message = ex.InnerException?.Message ?? ex.Message;\n\n    string exceptionXml = $@\"&lt;Ret&gt;\n                                &lt;StatusCode&gt;101&lt;\/StatusCode&gt;\n                                &lt;ErrorMessage&gt;{System.Security.SecurityElement.Escape(message)}&lt;\/ErrorMessage&gt;\n                                &lt;CONTENT&gt;&lt;\/CONTENT&gt;\n                            &lt;\/Ret&gt;\";\n\n    XmlDocument errorDoc = new XmlDocument();\n    errorDoc.LoadXml(exceptionXml);\n    return errorDoc.DocumentElement;\n}<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\uc608\uc81c2<\/h2>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:default decode:true \" title=\"catch\">catch (Exception ex)\n{\n    \/\/ 1. \uba54\uc2dc\uc9c0 \uad6c\uc131 (Top + Inner)\n    string message = ex.Message;\n\n    if (ex.InnerException != null)\n    {\n        message += \" | Inner: \" + ex.InnerException.Message;\n    }\n\n    \/\/ 2. StackTrace \ud3ec\ud568 (\uc635\uc158)\n    string stack = ex.StackTrace ?? \"\";\n\n    \/\/ 3. XML \uc548\uc804 \ucc98\ub9ac\n    string safeMessage = System.Security.SecurityElement.Escape(message);\n    string safeStack = System.Security.SecurityElement.Escape(stack);\n\n    \/\/ 4. XML \uad6c\uc131\n    string exceptionXml = $@\"&lt;Ret&gt;\n                                &lt;StatusCode&gt;101&lt;\/StatusCode&gt;\n                                &lt;ErrorMessage&gt;{safeMessage}&lt;\/ErrorMessage&gt;\n                                &lt;StackTrace&gt;{safeStack}&lt;\/StackTrace&gt;\n                                &lt;CONTENT&gt;&lt;\/CONTENT&gt;\n                            &lt;\/Ret&gt;\";\n\n    XmlDocument errorDoc = new XmlDocument();\n    errorDoc.LoadXml(exceptionXml);\n\n    return errorDoc.DocumentElement;\n}<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\ucd94\uac00 \uc911\uc694 \ud3ec\uc778\ud2b8 (\uc2e4\ubb34 \ud575\uc2ec)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1\ufe0f\u20e3 XML \uae68\uc9d0 \ubc29\uc9c0 (\ub9e4\uc6b0 \uc911\uc694)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">SecurityElement.Escape(message)<\/pre>\n\n\n\n<p>\ud83d\udc49 \uc548 \ud558\uba74 \uc774\ub7f0 \ubb38\uc81c \ubc1c\uc0dd:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>&lt;<\/code> <code>&amp;<\/code> \ud3ec\ud568 \uc2dc XML \ud30c\uc2f1 \uc5d0\ub7ec<\/li>\n\n\n\n<li>\uc2e4\uc81c \uc6b4\uc601\uc5d0\uc11c \uaf64 \uc790\uc8fc \ud130\uc9d0<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2\ufe0f\u20e3 InnerException\uc774 \ud56d\uc0c1 \ub354 \uc911\uc694\ud55c\uac00?<\/h3>\n\n\n\n<p>\ud83d\udc49 \uaf2d \uadf8\ub807\uc9c0 \uc54a\uc74c<\/p>\n\n\n\n<p>\uc608:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ex.Message = \"Top-level failure\"<\/code><\/li>\n\n\n\n<li><code>InnerException.Message = \"SQL timeout\"<\/code><\/li>\n<\/ul>\n\n\n\n<p>\ud83d\udc49 \uc0c1\ud669\uc5d0 \ub530\ub77c \ub458 \ub2e4 \ud544\uc694\ud560 \uc218\ub3c4 \uc788\uc74c<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd25 \uc2e4\ubb34\uc6a9 (\ucd94\ucc9c \ub85c\uadf8 \uc2a4\ud0c0\uc77c)<\/h2>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \" >string message = ex.Message;\n\nif (ex.InnerException != null)\n{\n    message += \" | Inner: \" + ex.InnerException.Message;\n}<\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \uacb0\ub860<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\ubc29\uc2dd<\/th><th>\uc548\uc804\uc131<\/th><th>\ucd94\ucc9c<\/th><\/tr><\/thead><tbody><tr><td>ex.InnerException.Message<\/td><td>\u274c \uc704\ud5d8 (null \uac00\ub2a5)<\/td><td>\u274c<\/td><\/tr><tr><td>ex.Message<\/td><td>\u2b55 \uc548\uc804<\/td><td>\u2b55<\/td><\/tr><tr><td>ex.InnerException?.Message ?? ex.Message<\/td><td>\u2b55 \uac00\uc7a5 \uc548\uc804<\/td><td>\u2b50 \ucd94\ucc9c<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\uc608\uc81c1 \uc608\uc81c2 \ucd94\uac00 \uc911\uc694 \ud3ec\uc778\ud2b8 (\uc2e4\ubb34 \ud575\uc2ec) 1\ufe0f\u20e3 XML \uae68\uc9d0 \ubc29\uc9c0 (\ub9e4\uc6b0 \uc911\uc694) SecurityElement.Escape(message) \ud83d\udc49 \uc548 \ud558\uba74 \uc774\ub7f0 \ubb38\uc81c \ubc1c\uc0dd: 2\ufe0f\u20e3 InnerException\uc774 \ud56d\uc0c1 \ub354 \uc911\uc694\ud55c\uac00? \ud83d\udc49 \uaf2d \uadf8\ub807\uc9c0 \uc54a\uc74c \uc608: \ud83d\udc49 \uc0c1\ud669\uc5d0 \ub530\ub77c \ub458 \ub2e4 \ud544\uc694\ud560 \uc218\ub3c4 \uc788\uc74c \ud83d\udd25 \uc2e4\ubb34\uc6a9 (\ucd94\ucc9c \ub85c\uadf8 \uc2a4\ud0c0\uc77c) \u2705 \uacb0\ub860 \ubc29\uc2dd \uc548\uc804\uc131 \ucd94\ucc9c ex.InnerException.Message \u274c \uc704\ud5d8 (null \uac00\ub2a5) \u274c ex.Message\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=951\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74,77],"tags":[],"class_list":["post-951","post","type-post","status-publish","format-standard","hentry","category-c-form","category-c-xml"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=951"}],"version-history":[{"count":2,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/951\/revisions"}],"predecessor-version":[{"id":953,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/951\/revisions\/953"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}