"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[3043],{1437:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>a,contentTitle:()=>l,default:()=>h,frontMatter:()=>r,metadata:()=>i,toc:()=>c});var s=o(5893),t=o(1151);const r={id:"oops",title:"4. Oops \u9759\u6001\u7c7b",sidebar_label:"4. Oops \u9759\u6001\u7c7b"},l=void 0,i={id:"global/oops",title:"4. Oops \u9759\u6001\u7c7b",description:"4.1 \u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38",source:"@site/docs/global/oops.mdx",sourceDirName:"global",slug:"/global/oops",permalink:"/docs/global/oops",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/global/oops.mdx",tags:[],version:"current",lastUpdatedBy:"MonkSoul",lastUpdatedAt:1675302258,formattedLastUpdatedAt:"Feb 2, 2023",frontMatter:{id:"oops",title:"4. Oops \u9759\u6001\u7c7b",sidebar_label:"4. Oops \u9759\u6001\u7c7b"},sidebar:"global",previous:{title:"3. DataValidator \u9759\u6001\u7c7b",permalink:"/docs/global/datavalidator"},next:{title:"5. LinqExpression \u9759\u6001\u7c7b",permalink:"/docs/global/linqexpression"}},a={},c=[{value:"4.1 \u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38",id:"41-\u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38",level:2},{value:"4.2 \u6307\u5b9a\u7c7b\u578b\u7684\u5f02\u5e38",id:"42-\u6307\u5b9a\u7c7b\u578b\u7684\u5f02\u5e38",level:2},{value:"4.3 \u72b6\u6001\u7801\u5f02\u5e38",id:"43-\u72b6\u6001\u7801\u5f02\u5e38",level:2},{value:"4.4 \u72b6\u6001\u7801\u5f02\u5e38",id:"44-\u72b6\u6001\u7801\u5f02\u5e38",level:2},{value:"4.5 \u5f02\u5e38\u65b9\u6cd5\u91cd\u8bd5",id:"45-\u5f02\u5e38\u65b9\u6cd5\u91cd\u8bd5",level:2},{value:"4.6 \u629b\u51fa\u4e1a\u52a1\u5f02\u5e38",id:"46-\u629b\u51fa\u4e1a\u52a1\u5f02\u5e38",level:2},{value:"4.7 \u8bbe\u7f6e\u54cd\u5e94\u72b6\u6001\u7801",id:"47-\u8bbe\u7f6e\u54cd\u5e94\u72b6\u6001\u7801",level:2},{value:"4.8 \u643a\u5e26\u989d\u5916\u6570\u636e",id:"48-\u643a\u5e26\u989d\u5916\u6570\u636e",level:2}];function d(e){const n={admonition:"admonition",code:"code",h2:"h2",p:"p",pre:"pre",...(0,t.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h2,{id:"41-\u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38",children:"4.1 \u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'throw Oops.Oh("\u5f02\u5e38\u6d88\u606f");\r\nthrow Oops.Oh("\u5f02\u5e38\u6d88\u606f\uff1a{0}", "\u51fa\u9519\u4e86");\n'})}),"\n",(0,s.jsx)(n.h2,{id:"42-\u6307\u5b9a\u7c7b\u578b\u7684\u5f02\u5e38",children:"4.2 \u6307\u5b9a\u7c7b\u578b\u7684\u5f02\u5e38"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'throw Oops.Oh("\u5f02\u5e38\u6d88\u606f", typeof(ArgumentNullException));\r\nthrow Oops.Oh("\u5f02\u5e38\u6d88\u606f\uff1a{0}", typeof(ArgumentNullException), "\u51fa\u9519\u4e86");\n'})}),"\n",(0,s.jsx)(n.h2,{id:"43-\u72b6\u6001\u7801\u5f02\u5e38",children:"4.3 \u72b6\u6001\u7801\u5f02\u5e38"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'throw Oops.Oh(1000);\r\nthrow Oops.Oh(1000, "\u51fa\u9519\u4e86");\n'})}),"\n",(0,s.jsx)(n.h2,{id:"44-\u72b6\u6001\u7801\u5f02\u5e38",children:"4.4 \u72b6\u6001\u7801\u5f02\u5e38"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'throw Oops.Oh(1000, typeof(ArgumentNullException));\r\nthrow Oops.Oh(1000, typeof(ArgumentNullException), "\u51fa\u9519\u4e86");\n'})}),"\n",(0,s.jsx)(n.h2,{id:"45-\u5f02\u5e38\u65b9\u6cd5\u91cd\u8bd5",children:"4.5 \u5f02\u5e38\u65b9\u6cd5\u91cd\u8bd5"}),"\n",(0,s.jsx)(n.admonition,{title:"\u8c03\u6574\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"v2.17.0+"})," \u7248\u672c\u4e0b\u9762\u65b9\u6cd5\u8bf7\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"Retry.Invoke()/Retry.InvokeAsync()"})," \u66ff\u4ee3\u3002"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"Oops.Retry(() => {\r\n // Do.....\r\n}, 3, 1000);\r\n\r\n// \u5e26\u8fd4\u56de\u503c\r\nvar value = Oops.Retry(() => {\r\n // Do.....\r\n}, 3, 1000);\r\n\r\n// \u53ea\u6709\u7279\u5b9a\u5f02\u5e38\u624d\u76d1\u542c\r\nOops.Retry(() => {\r\n\r\n}, 3, 1000, typeof(ArgumentNullException));\n"})}),"\n",(0,s.jsx)(n.h2,{id:"46-\u629b\u51fa\u4e1a\u52a1\u5f02\u5e38",children:"4.6 \u629b\u51fa\u4e1a\u52a1\u5f02\u5e38"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'throw Oops.Bah("\u7528\u6237\u540d\u6216\u5bc6\u7801\u9519\u8bef");\r\nthrow Oops.Bah(1000);\n'})}),"\n",(0,s.jsx)(n.h2,{id:"47-\u8bbe\u7f6e\u54cd\u5e94\u72b6\u6001\u7801",children:"4.7 \u8bbe\u7f6e\u54cd\u5e94\u72b6\u6001\u7801"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'throw Oops.Oh("\u9519\u8bef\u4e86").StatusCode(502);\n'})}),"\n",(0,s.jsx)(n.h2,{id:"48-\u643a\u5e26\u989d\u5916\u6570\u636e",children:"4.8 \u643a\u5e26\u989d\u5916\u6570\u636e"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'throw Oops.Oh("\u9519\u8bef\u4e86").WithData(new Model {});\n'})})]})}function h(e={}){const{wrapper:n}={...(0,t.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},1151:(e,n,o)=>{o.d(n,{Z:()=>i,a:()=>l});var s=o(7294);const t={},r=s.createContext(t);function l(e){const n=s.useContext(r);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]);