error.html 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  1. <!doctype html>
  2. <html lang="zh" class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <meta name="description" content="Net document">
  7. <meta name="author" content="劉強東">
  8. <link rel="prev" href="track.html">
  9. <link rel="next" href="error-single.html">
  10. <link rel="icon" href="img/book-open.svg">
  11. <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.5.48">
  12. <title>错误处理 - Net</title>
  13. <link rel="stylesheet" href="assets/stylesheets/main.6f8fc17f.min.css">
  14. <link rel="stylesheet" href="assets/stylesheets/palette.06af60db.min.css">
  15. <script src="https://unpkg.com/iframe-worker/shim"></script>
  16. <link rel="stylesheet" href="css/extra.css">
  17. <script>__md_scope=new URL(".",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
  18. </head>
  19. <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="white" data-md-color-accent="indigo">
  20. <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
  21. <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
  22. <label class="md-overlay" for="__drawer"></label>
  23. <div data-md-component="skip">
  24. </div>
  25. <div data-md-component="announce">
  26. </div>
  27. <header class="md-header md-header--shadow" data-md-component="header">
  28. <nav class="md-header__inner md-grid" aria-label="页眉">
  29. <a href="index.html" title="Net" class="md-header__button md-logo" aria-label="Net" data-md-component="logo">
  30. <img src="img/book-open.svg" alt="logo">
  31. </a>
  32. <label class="md-header__button md-icon" for="__drawer">
  33. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
  34. </label>
  35. <div class="md-header__title" data-md-component="header-title">
  36. <div class="md-header__ellipsis">
  37. <div class="md-header__topic">
  38. <span class="md-ellipsis">
  39. Net
  40. </span>
  41. </div>
  42. <div class="md-header__topic" data-md-component="header-topic">
  43. <span class="md-ellipsis">
  44. 错误处理
  45. </span>
  46. </div>
  47. </div>
  48. </div>
  49. <form class="md-header__option" data-md-component="palette">
  50. <input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="white" data-md-color-accent="indigo" aria-hidden="true" type="radio" name="__palette" id="__palette_0">
  51. </form>
  52. <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
  53. <label class="md-header__button md-icon" for="__search">
  54. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
  55. </label>
  56. <div class="md-search" data-md-component="search" role="dialog">
  57. <label class="md-search__overlay" for="__search"></label>
  58. <div class="md-search__inner" role="search">
  59. <form class="md-search__form" name="search">
  60. <input type="text" class="md-search__input" name="query" aria-label="搜索" placeholder="搜索" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
  61. <label class="md-search__icon md-icon" for="__search">
  62. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
  63. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
  64. </label>
  65. <nav class="md-search__options" aria-label="查找">
  66. <a href="javascript:void(0)" class="md-search__icon md-icon" title="分享" aria-label="分享" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1">
  67. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91s2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08"/></svg>
  68. </a>
  69. <button type="reset" class="md-search__icon md-icon" title="清空当前内容" aria-label="清空当前内容" tabindex="-1">
  70. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
  71. </button>
  72. </nav>
  73. <div class="md-search__suggest" data-md-component="search-suggest"></div>
  74. </form>
  75. <div class="md-search__output">
  76. <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
  77. <div class="md-search-result" data-md-component="search-result">
  78. <div class="md-search-result__meta">
  79. 正在初始化搜索引擎
  80. </div>
  81. <ol class="md-search-result__list" role="presentation"></ol>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="md-header__source">
  88. <a href="https://github.com/liangjingkanji/Net" title="前往仓库" class="md-source" data-md-component="source">
  89. <div class="md-source__icon md-icon">
  90. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
  91. </div>
  92. <div class="md-source__repository">
  93. GitHub
  94. </div>
  95. </a>
  96. </div>
  97. </nav>
  98. </header>
  99. <div class="md-container" data-md-component="container">
  100. <main class="md-main" data-md-component="main">
  101. <div class="md-main__inner md-grid">
  102. <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
  103. <div class="md-sidebar__scrollwrap">
  104. <div class="md-sidebar__inner">
  105. <nav class="md-nav md-nav--primary" aria-label="导航栏" data-md-level="0">
  106. <label class="md-nav__title" for="__drawer">
  107. <a href="index.html" title="Net" class="md-nav__button md-logo" aria-label="Net" data-md-component="logo">
  108. <img src="img/book-open.svg" alt="logo">
  109. </a>
  110. Net
  111. </label>
  112. <div class="md-nav__source">
  113. <a href="https://github.com/liangjingkanji/Net" title="前往仓库" class="md-source" data-md-component="source">
  114. <div class="md-source__icon md-icon">
  115. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
  116. </div>
  117. <div class="md-source__repository">
  118. GitHub
  119. </div>
  120. </a>
  121. </div>
  122. <ul class="md-nav__list" data-md-scrollfix>
  123. <li class="md-nav__item">
  124. <a href="index.html" class="md-nav__link">
  125. <span class="md-ellipsis">
  126. 使用
  127. </span>
  128. </a>
  129. </li>
  130. <li class="md-nav__item">
  131. <a href="coroutine-request.html" class="md-nav__link">
  132. <span class="md-ellipsis">
  133. 协程请求
  134. </span>
  135. </a>
  136. </li>
  137. <li class="md-nav__item">
  138. <a href="scope.html" class="md-nav__link">
  139. <span class="md-ellipsis">
  140. 作用域
  141. </span>
  142. </a>
  143. </li>
  144. <li class="md-nav__item">
  145. <a href="sync-request.html" class="md-nav__link">
  146. <span class="md-ellipsis">
  147. 同步请求
  148. </span>
  149. </a>
  150. </li>
  151. <li class="md-nav__item">
  152. <a href="request.html" class="md-nav__link">
  153. <span class="md-ellipsis">
  154. 请求参数
  155. </span>
  156. </a>
  157. </li>
  158. <li class="md-nav__item">
  159. <a href="config.html" class="md-nav__link">
  160. <span class="md-ellipsis">
  161. 全局配置
  162. </span>
  163. </a>
  164. </li>
  165. <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
  166. <a href="converter.html" class="md-nav__link">
  167. <span class="md-ellipsis">
  168. 请求结果
  169. </span>
  170. <span class="md-nav__icon md-icon"></span>
  171. </a>
  172. </li>
  173. <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
  174. <a href="auto-dialog.html" class="md-nav__link">
  175. <span class="md-ellipsis">
  176. 自动化
  177. </span>
  178. <span class="md-nav__icon md-icon"></span>
  179. </a>
  180. </li>
  181. <li class="md-nav__item">
  182. <a href="thread.html" class="md-nav__link">
  183. <span class="md-ellipsis">
  184. 切换线程
  185. </span>
  186. </a>
  187. </li>
  188. <li class="md-nav__item">
  189. <a href="view-model.html" class="md-nav__link">
  190. <span class="md-ellipsis">
  191. ViewModel
  192. </span>
  193. </a>
  194. </li>
  195. <li class="md-nav__item">
  196. <a href="track.html" class="md-nav__link">
  197. <span class="md-ellipsis">
  198. 异常追踪
  199. </span>
  200. </a>
  201. </li>
  202. <li class="md-nav__item md-nav__item--active md-nav__item--nested">
  203. <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_12" checked>
  204. <label class="md-nav__link" for="__nav_12" id="__nav_12_label" tabindex="0">
  205. <span class="md-ellipsis">
  206. 错误处理
  207. </span>
  208. <span class="md-nav__icon md-icon"></span>
  209. </label>
  210. <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_12_label" aria-expanded="true">
  211. <label class="md-nav__title" for="__nav_12">
  212. <span class="md-nav__icon md-icon"></span>
  213. 错误处理
  214. </label>
  215. <ul class="md-nav__list" data-md-scrollfix>
  216. <li class="md-nav__item md-nav__item--active">
  217. <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
  218. <a href="error.html" class="md-nav__link md-nav__link--active">
  219. <span class="md-ellipsis">
  220. 错误处理
  221. </span>
  222. </a>
  223. </li>
  224. <li class="md-nav__item">
  225. <a href="error-single.html" class="md-nav__link">
  226. <span class="md-ellipsis">
  227. 单例捕获
  228. </span>
  229. </a>
  230. </li>
  231. <li class="md-nav__item">
  232. <a href="error-global.html" class="md-nav__link">
  233. <span class="md-ellipsis">
  234. 全局捕获
  235. </span>
  236. </a>
  237. </li>
  238. <li class="md-nav__item">
  239. <a href="error-tip.html" class="md-nav__link">
  240. <span class="md-ellipsis">
  241. 自定义错误提示
  242. </span>
  243. </a>
  244. </li>
  245. <li class="md-nav__item">
  246. <a href="error-throws.html" class="md-nav__link">
  247. <span class="md-ellipsis">
  248. 自定义异常抛出
  249. </span>
  250. </a>
  251. </li>
  252. </ul>
  253. </nav>
  254. </li>
  255. <li class="md-nav__item">
  256. <a href="okhttp-client.html" class="md-nav__link">
  257. <span class="md-ellipsis">
  258. OkHttpClient
  259. </span>
  260. </a>
  261. </li>
  262. <li class="md-nav__item">
  263. <a href="interceptor.html" class="md-nav__link">
  264. <span class="md-ellipsis">
  265. 拦截器
  266. </span>
  267. </a>
  268. </li>
  269. <li class="md-nav__item">
  270. <a href="https.html" class="md-nav__link">
  271. <span class="md-ellipsis">
  272. Https证书
  273. </span>
  274. </a>
  275. </li>
  276. <li class="md-nav__item">
  277. <a href="cookie.html" class="md-nav__link">
  278. <span class="md-ellipsis">
  279. Cookie
  280. </span>
  281. </a>
  282. </li>
  283. <li class="md-nav__item">
  284. <a href="cache.html" class="md-nav__link">
  285. <span class="md-ellipsis">
  286. 缓存
  287. </span>
  288. </a>
  289. </li>
  290. <li class="md-nav__item">
  291. <a href="tag.html" class="md-nav__link">
  292. <span class="md-ellipsis">
  293. 标签/额外
  294. </span>
  295. </a>
  296. </li>
  297. <li class="md-nav__item">
  298. <a href="upload-file.html" class="md-nav__link">
  299. <span class="md-ellipsis">
  300. 上传文件
  301. </span>
  302. </a>
  303. </li>
  304. <li class="md-nav__item">
  305. <a href="download-file.html" class="md-nav__link">
  306. <span class="md-ellipsis">
  307. 下载文件
  308. </span>
  309. </a>
  310. </li>
  311. <li class="md-nav__item">
  312. <a href="progress.html" class="md-nav__link">
  313. <span class="md-ellipsis">
  314. 进度监听
  315. </span>
  316. </a>
  317. </li>
  318. <li class="md-nav__item">
  319. <a href="cancel.html" class="md-nav__link">
  320. <span class="md-ellipsis">
  321. 取消请求
  322. </span>
  323. </a>
  324. </li>
  325. <li class="md-nav__item">
  326. <a href="repeat-request.html" class="md-nav__link">
  327. <span class="md-ellipsis">
  328. 重复请求
  329. </span>
  330. </a>
  331. </li>
  332. <li class="md-nav__item">
  333. <a href="debounce.html" class="md-nav__link">
  334. <span class="md-ellipsis">
  335. 搜索节流
  336. </span>
  337. </a>
  338. </li>
  339. <li class="md-nav__item">
  340. <a href="fastest.html" class="md-nav__link">
  341. <span class="md-ellipsis">
  342. 最快请求结果
  343. </span>
  344. </a>
  345. </li>
  346. <li class="md-nav__item">
  347. <a href="log-recorder.html" class="md-nav__link">
  348. <span class="md-ellipsis">
  349. 日志插件
  350. </span>
  351. </a>
  352. </li>
  353. <li class="md-nav__item">
  354. <a href="log-notice.html" class="md-nav__link">
  355. <span class="md-ellipsis">
  356. 日志通知
  357. </span>
  358. </a>
  359. </li>
  360. <li class="md-nav__item">
  361. <a href="timing.html" class="md-nav__link">
  362. <span class="md-ellipsis">
  363. 限时/定时请求
  364. </span>
  365. </a>
  366. </li>
  367. <li class="md-nav__item">
  368. <a href="callback.html" class="md-nav__link">
  369. <span class="md-ellipsis">
  370. Callback
  371. </span>
  372. </a>
  373. </li>
  374. <li class="md-nav__item">
  375. <a href="interval.html" class="md-nav__link">
  376. <span class="md-ellipsis">
  377. 轮询器/倒计时
  378. </span>
  379. </a>
  380. </li>
  381. <li class="md-nav__item">
  382. <a href="https://github.com/liangjingkanji/Net/discussions" class="md-nav__link">
  383. <span class="md-ellipsis">
  384. 社区讨论
  385. </span>
  386. </a>
  387. </li>
  388. <li class="md-nav__item">
  389. <a href="issues.html" class="md-nav__link">
  390. <span class="md-ellipsis">
  391. 常见问题
  392. </span>
  393. </a>
  394. </li>
  395. <li class="md-nav__item">
  396. <a href="updates.html" class="md-nav__link">
  397. <span class="md-ellipsis">
  398. 更新日志
  399. </span>
  400. </a>
  401. </li>
  402. <li class="md-nav__item">
  403. <a href="api/index.html" class="md-nav__link">
  404. <span class="md-ellipsis">
  405. 3.x文档
  406. </span>
  407. </a>
  408. </li>
  409. </ul>
  410. </nav>
  411. </div>
  412. </div>
  413. </div>
  414. <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
  415. <div class="md-sidebar__scrollwrap">
  416. <div class="md-sidebar__inner">
  417. <nav class="md-nav md-nav--secondary" aria-label="目录">
  418. </nav>
  419. </div>
  420. </div>
  421. </div>
  422. <div class="md-content" data-md-component="content">
  423. <article class="md-content__inner md-typeset">
  424. <h1>错误处理</h1>
  425. <p>Net有完善的错误处理机制, 具备捕获异常/取消请求/错误提示/追踪链路</p>
  426. <div class="admonition success">
  427. <p class="admonition-title">收集网络日志</p>
  428. <p>在Net作用域内发生的异常都会被全局错误处理捕获, 可以将其筛选上传日志</p>
  429. </div>
  430. <p><br>
  431. 以下位置抛出异常会被捕获</p>
  432. <table>
  433. <thead>
  434. <tr>
  435. <th>函数</th>
  436. <th>描述</th>
  437. </tr>
  438. </thead>
  439. <tbody>
  440. <tr>
  441. <td>作用域</td>
  442. <td><code>scopeXX</code>代码块中</td>
  443. </tr>
  444. <tr>
  445. <td>拦截器</td>
  446. <td><code>Interceptor/RequestInterceptor</code></td>
  447. </tr>
  448. <tr>
  449. <td>转换器</td>
  450. <td><code>NetConverter</code></td>
  451. </tr>
  452. </tbody>
  453. </table>
  454. <p>如果捕获到错误默认会执行以下操作</p>
  455. <ol>
  456. <li><code>Logcat</code>输出异常堆栈信息, <a href="error-throws.html">自定义异常抛出</a></li>
  457. <li><code>Toast</code>显示错误文本, <a href="error-tip.html">自定义错误提示</a></li>
  458. </ol>
  459. <p><br></p>
  460. <div class="admonition failure">
  461. <p class="admonition-title">捕获不到异常</p>
  462. <p>如果请求未执行<code>await()</code>, 那么即使发生错误也不会被捕获到</p>
  463. </div>
  464. <p><br>
  465. 自定义请阅读<a href="error-global.html">全局错误处理</a></p>
  466. </article>
  467. </div>
  468. <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
  469. </div>
  470. <button type="button" class="md-top md-icon" data-md-component="top" hidden>
  471. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg>
  472. 回到页面顶部
  473. </button>
  474. </main>
  475. <!-- Footer -->
  476. <footer class="md-footer">
  477. <!-- Link to previous and/or next page -->
  478. <nav class="md-footer__inner md-grid" aria-label="footer.title">
  479. <!-- Link to previous page -->
  480. <a href="track.html" class="md-footer__link md-footer__link--prev" rel="prev">
  481. <div class="md-footer__button md-icon">
  482. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
  483. </div>
  484. <div class="md-footer__title">
  485. <div class="md-ellipsis">
  486. <span class="md-footer__direction">
  487. 上一页
  488. </span>
  489. 异常追踪
  490. </div>
  491. </div>
  492. </a>
  493. <!-- Link to next page -->
  494. <a href="error-single.html" class="md-footer__link md-footer__link--next" rel="next">
  495. <div class="md-footer__title">
  496. <div class="md-ellipsis">
  497. <span class="md-footer__direction">
  498. 下一页
  499. </span>
  500. 单例捕获
  501. </div>
  502. </div>
  503. <div class="md-footer__button md-icon">
  504. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11z"/></svg>
  505. </div>
  506. </a>
  507. </nav>
  508. <!-- Further information -->
  509. <div class="md-footer-meta md-typeset">
  510. <div class="md-footer-meta__inner md-grid">
  511. <!-- Copyright and theme information -->
  512. <div class="md-footer-copyright">
  513. <a href="https://github.com/liangjingkanji" target="_blank" rel="noopener">
  514. <div class="md-footer-copyright__highlight">
  515. Copyright &copy; 2018 - 2023 劉強東
  516. </div>
  517. </a>
  518. </div>
  519. <!-- Social links -->
  520. <div class="md-social">
  521. <a href="https://github.com/liangjingkanji" target="_blank" rel="noopener" title="github.com" class="md-social__link">
  522. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg>
  523. </a>
  524. <a href="https://raw.githubusercontent.com/liangjingkanji/liangjingkanji/master/img/group-qrcode.png" target="_blank" rel="noopener" title="raw.githubusercontent.com" class="md-social__link">
  525. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M433.754 420.445c-11.526 1.393-44.86-52.741-44.86-52.741 0 31.345-16.136 72.247-51.051 101.786 16.842 5.192 54.843 19.167 45.803 34.421-7.316 12.343-125.51 7.881-159.632 4.037-34.122 3.844-152.316 8.306-159.632-4.037-9.045-15.25 28.918-29.214 45.783-34.415-34.92-29.539-51.059-70.445-51.059-101.792 0 0-33.334 54.134-44.859 52.741-5.37-.65-12.424-29.644 9.347-99.704 10.261-33.024 21.995-60.478 40.144-105.779C60.683 98.063 108.982.006 224 0c113.737.006 163.156 96.133 160.264 214.963 18.118 45.223 29.912 72.85 40.144 105.778 21.768 70.06 14.716 99.053 9.346 99.704"/></svg>
  526. </a>
  527. <a href="https://github.com/liangjingkanji/Net/discussions" target="_blank" rel="noopener" title="github.com" class="md-social__link">
  528. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M391.17 103.47h-38.63v109.7h38.63ZM285 103h-38.63v109.75H285ZM120.83 0 24.31 91.42v329.16h115.83V512l96.53-91.42h77.25L487.69 256V0Zm328.24 237.75-77.22 73.12h-77.24l-67.6 64v-64h-86.87V36.58h308.93Z"/></svg>
  529. </a>
  530. </div>
  531. </div>
  532. </div>
  533. </footer>
  534. </div>
  535. <div class="md-dialog" data-md-component="dialog">
  536. <div class="md-dialog__inner md-typeset"></div>
  537. </div>
  538. <script id="__config" type="application/json">{"base": ".", "features": ["navigation.top", "navigation.prune", "navigation.footer", "navigation.instant", "search.highlight", "search.suggest", "search.share", "content.code.copy", "content.code.annotate"], "search": "assets/javascripts/workers/search.6ce7567c.min.js", "translations": {"clipboard.copied": "\u5df2\u590d\u5236", "clipboard.copy": "\u590d\u5236", "search.result.more.one": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.more.other": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 # \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.none": "\u6ca1\u6709\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.one": "\u627e\u5230 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.other": "# \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.placeholder": "\u952e\u5165\u4ee5\u5f00\u59cb\u641c\u7d22", "search.result.term.missing": "\u7f3a\u5c11", "select.version": "\u9009\u62e9\u5f53\u524d\u7248\u672c"}}</script>
  539. <script src="assets/javascripts/bundle.83f73b43.min.js"></script>
  540. </body>
  541. </html>