[{"data":1,"prerenderedAt":1599,"buildId":1600},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Ferror-handling":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1598,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Ferror-handling.md",{},"Handle errors",{"type":8,"value":9,"toc":1577},"minimark",[10,23,28,35,132,154,158,172,356,474,490,513,517,540,702,710,714,729,845,852,856,872,974,978,992,1097,1117,1144,1181,1194,1299,1332,1339,1343,1352,1418,1442,1446,1450,1460,1463,1471,1505,1512,1530,1536,1560],[11,12,13,14,18,19,22],"p",{},"Handle HTTP and network errors in the generated Axios client with ",[15,16,17],"code",{},"ResponseError",", or return errors as values with ",[15,20,21],{},"throwOnError: false",".",[24,25,27],"h2",{"id":26},"what-a-call-does","What a call does",[11,29,30,31,34],{},"Only a non-2xx response depends on ",[15,32,33],{},"throwOnError",":",[36,37,38,51],"table",{},[39,40,41],"thead",{},[42,43,44,48],"tr",{},[45,46,47],"th",{},"What happens",[45,49,50],{},"Result",[52,53,54,66,87,101,110,121],"tbody",{},[42,55,56,60],{},[57,58,59],"td",{},"2xx response",[57,61,62,63,22],{},"Resolves with ",[15,64,65],{},"data",[42,67,68,71],{},[57,69,70],{},"Non-2xx response",[57,72,73,74,76,77,79,80,83,84,22],{},"Throws a ",[15,75,17],{},". With ",[15,78,21],{},", resolves with ",[15,81,82],{},"error"," and ",[15,85,86],{},"status",[42,88,89,96],{},[57,90,91,92,95],{},"A body fails its schema (",[15,93,94],{},"validator"," on)",[57,97,73,98,22],{},[15,99,100],{},"ValidationError",[42,102,103,106],{},[57,104,105],{},"Invalid JSON under a JSON media type",[57,107,73,108,22],{},[15,109,100],{},[42,111,112,115],{},[57,113,114],{},"Network failure, DNS failure, or timeout",[57,116,117,118,22],{},"Rejects with the native ",[15,119,120],{},"AxiosError",[42,122,123,129],{},[57,124,125,126],{},"Aborted ",[15,127,128],{},"signal",[57,130,131],{},"Rejects with the signal's reason.",[11,133,134,135,138,139,146,147,149,150,153],{},"Every failure that rejects with an ",[15,136,137],{},"Error"," also reaches ",[140,141,143],"a",{"href":142},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests#add-interceptors",[15,144,145],{},"client.interceptors.error",". An abort whose reason is not an ",[15,148,137],{},", such as ",[15,151,152],{},"abort('canceled')",", skips it.",[24,155,157],{"id":156},"catch-a-responseerror","Catch a ResponseError",[11,159,160,161,164,165,168,169,171],{},"Narrow with ",[15,162,163],{},"ResponseError.is(error)"," instead of ",[15,166,167],{},"instanceof",", because each generated package bundles its own ",[15,170,17],{}," class:",[173,174,178],"pre",{"language":175,"code":176,"class":177},"typescript","import { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\nimport { ResponseError } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\ntry {\n const { data } = await getPetById({ path: { petId: 1 } })\n} catch (error) {\n if (ResponseError.is(error)) console.error(error.status, error.data) \u002F\u002F 404, the parsed error body\n}","highlights",[15,179,181,208,209,208,226,208,228,208,236,208,282,208,297,208,351],{"class":180},"language-typescript",[182,183,186,190,194,198,201,204],"span",{"class":184,"style":185},"line","display: inline",[182,187,189],{"style":188},"color:#d73a49;--hls-dark:#f97583","import ",[182,191,193],{"style":192},"color:#005cc5;--hls-dark:#79b8ff","{ ",[182,195,197],{"style":196},"color:#24292e;--hls-dark:#e1e4e8","getPetById ",[182,199,200],{"style":192},"} ",[182,202,203],{"style":188},"from ",[182,205,207],{"style":206},"color:#032f62;--hls-dark:#9ecbff","'.\u002Fgen\u002Fclients\u002FgetPetById'","\n",[182,210,211,213,215,219,221,223],{"class":184,"style":185},[182,212,189],{"style":188},[182,214,193],{"style":192},[182,216,218],{"style":217},"color:#6f42c1;--hls-dark:#b392f0","ResponseError ",[182,220,200],{"style":192},[182,222,203],{"style":188},[182,224,225],{"style":206},"'.\u002Fgen\u002F.kubb\u002Fclient'",[182,227],{"class":184,"style":185},[182,229,230,233],{"class":184,"style":185},[182,231,232],{"style":188},"try ",[182,234,235],{"style":192},"{",[182,237,238,241,244,246,249,251,254,257,260,263,266,269,271,274,276,279],{"class":184,"style":185},[182,239,240],{"style":192}," ",[182,242,243],{"style":188},"const ",[182,245,193],{"style":192},[182,247,248],{"style":196},"data ",[182,250,200],{"style":192},[182,252,253],{"style":188},"= ",[182,255,256],{"style":188},"await ",[182,258,259],{"style":217},"getPetById",[182,261,262],{"style":192},"({ ",[182,264,265],{"style":192},"path",[182,267,268],{"style":188},": ",[182,270,193],{"style":192},[182,272,273],{"style":192},"petId",[182,275,268],{"style":188},[182,277,278],{"style":192},"1 ",[182,280,281],{"style":192},"} })",[182,283,284,286,289,292,294],{"class":184,"style":185},[182,285,200],{"style":192},[182,287,288],{"style":188},"catch ",[182,290,291],{"style":192},"(",[182,293,82],{"style":196},[182,295,296],{"style":192},") {",[182,298,299,301,304,306,308,310,313,315,317,320,323,325,327,329,331,333,335,338,340,342,344,347],{"class":184,"style":185},[182,300,240],{"style":192},[182,302,303],{"style":188},"if ",[182,305,291],{"style":192},[182,307,17],{"style":217},[182,309,22],{"style":188},[182,311,312],{"style":217},"is",[182,314,291],{"style":192},[182,316,82],{"style":196},[182,318,319],{"style":192},")) ",[182,321,322],{"style":196},"console",[182,324,22],{"style":188},[182,326,82],{"style":217},[182,328,291],{"style":192},[182,330,82],{"style":196},[182,332,22],{"style":188},[182,334,86],{"style":192},[182,336,337],{"style":188},", ",[182,339,82],{"style":196},[182,341,22],{"style":188},[182,343,65],{"style":192},[182,345,346],{"style":192},") ",[182,348,350],{"style":349},"color:#6a737d;--hls-dark:#6a737d","\u002F\u002F 404, the parsed error body",[182,352,353],{"class":184,"style":185},[182,354,355],{"style":192},"}",[173,357,359],{"language":175,"code":358,"class":177},"class ResponseError extends Error {\n data: TError \u002F\u002F the parsed error body\n status: number\n statusText: string\n contentType: string | undefined\n headers: Headers \u002F\u002F such as error.headers.get('Retry-After')\n request: AxiosRequestConfig\n response: AxiosResponse\n}",[15,360,361,208,376,208,390,208,401,208,413,208,431,208,446,208,458,208,470],{"class":180},[182,362,363,366,368,371,374],{"class":184,"style":185},[182,364,365],{"style":188},"class ",[182,367,218],{"style":217},[182,369,370],{"style":188},"extends ",[182,372,373],{"style":217},"Error ",[182,375,235],{"style":192},[182,377,378,380,382,384,387],{"class":184,"style":185},[182,379,240],{"style":192},[182,381,65],{"style":192},[182,383,268],{"style":196},[182,385,386],{"style":217},"TError ",[182,388,389],{"style":349},"\u002F\u002F the parsed error body",[182,391,392,394,396,398],{"class":184,"style":185},[182,393,240],{"style":349},[182,395,86],{"style":196},[182,397,268],{"style":196},[182,399,400],{"style":217},"number",[182,402,403,405,408,410],{"class":184,"style":185},[182,404,240],{"style":217},[182,406,407],{"style":196},"statusText",[182,409,268],{"style":196},[182,411,412],{"style":217},"string",[182,414,415,417,420,422,425,428],{"class":184,"style":185},[182,416,240],{"style":217},[182,418,419],{"style":196},"contentType",[182,421,268],{"style":196},[182,423,424],{"style":217},"string ",[182,426,427],{"style":188},"| ",[182,429,430],{"style":192},"undefined",[182,432,433,435,438,440,443],{"class":184,"style":185},[182,434,240],{"style":192},[182,436,437],{"style":196},"headers",[182,439,268],{"style":196},[182,441,442],{"style":217},"Headers ",[182,444,445],{"style":349},"\u002F\u002F such as error.headers.get('Retry-After')",[182,447,448,450,453,455],{"class":184,"style":185},[182,449,240],{"style":349},[182,451,452],{"style":196},"request",[182,454,268],{"style":196},[182,456,457],{"style":217},"AxiosRequestConfig",[182,459,460,462,465,467],{"class":184,"style":185},[182,461,240],{"style":217},[182,463,464],{"style":196},"response",[182,466,268],{"style":196},[182,468,469],{"style":217},"AxiosResponse",[182,471,472],{"class":184,"style":185},[182,473,355],{"style":192},[11,475,476,477,480,481,484,485,83,487,489],{},"The ",[15,478,479],{},"message"," leaves out the query string: ",[15,482,483],{},"GET https:\u002F\u002Fapi.example.com\u002Fpets\u002F1 failed with status 404 Not Found",". ",[15,486,452],{},[15,488,464],{}," keep the full URL, so redact them before you log the whole error.",[491,492,494,495,501,502,505,506,509,510,22],"blockquote",{"as":493},"note","The examples set ",[140,496,498],{"href":497},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#integertype",[15,499,500],{},"integerType: 'number'",". With the default ",[15,503,504],{},"bigint",", an ",[15,507,508],{},"int64"," id takes ",[15,511,512],{},"1n",[24,514,516],{"id":515},"narrow-a-thrown-error-by-status","Narrow a thrown error by status",[11,518,519,522,523,525,526,528,529,531,532,535,536,34],{},[15,520,521],{},"isResponseError\u003CResponses>(error)"," narrows a caught error to one operation's ",[15,524,17],{},". A check on ",[15,527,86],{}," then narrows ",[15,530,65],{},". For range keys such as ",[15,533,534],{},"4xx",", see ",[140,537,539],{"href":538},"#status-ranges","Status ranges",[173,541,543],{"language":175,"code":542,"class":177},"import { isResponseError } from '.\u002Fgen\u002F.kubb\u002Fclient'\nimport type { GetPetByIdResponses } from '.\u002Fgen\u002Ftypes\u002FGetPetById'\n\ntry {\n await getPetById({ path: { petId: 7 } })\n} catch (error) {\n if (isResponseError\u003CGetPetByIdResponses>(error) && error.status === 404) {\n console.error(error.data) \u002F\u002F GetPetById404\n }\n}",[15,544,545,208,560,208,579,208,581,208,587,208,612,208,624,208,668,208,692,208,698],{"class":180},[182,546,547,549,551,554,556,558],{"class":184,"style":185},[182,548,189],{"style":188},[182,550,193],{"style":192},[182,552,553],{"style":196},"isResponseError ",[182,555,200],{"style":192},[182,557,203],{"style":188},[182,559,225],{"style":206},[182,561,562,564,567,569,572,574,576],{"class":184,"style":185},[182,563,189],{"style":188},[182,565,566],{"style":196},"type ",[182,568,193],{"style":192},[182,570,571],{"style":217},"GetPetByIdResponses ",[182,573,200],{"style":192},[182,575,203],{"style":188},[182,577,578],{"style":206},"'.\u002Fgen\u002Ftypes\u002FGetPetById'",[182,580],{"class":184,"style":185},[182,582,583,585],{"class":184,"style":185},[182,584,232],{"style":188},[182,586,235],{"style":192},[182,588,589,591,593,595,597,599,601,603,605,607,610],{"class":184,"style":185},[182,590,240],{"style":192},[182,592,256],{"style":188},[182,594,259],{"style":217},[182,596,262],{"style":192},[182,598,265],{"style":192},[182,600,268],{"style":188},[182,602,193],{"style":192},[182,604,273],{"style":192},[182,606,268],{"style":188},[182,608,609],{"style":192},"7 ",[182,611,281],{"style":192},[182,613,614,616,618,620,622],{"class":184,"style":185},[182,615,200],{"style":192},[182,617,288],{"style":188},[182,619,291],{"style":192},[182,621,82],{"style":196},[182,623,296],{"style":192},[182,625,626,628,630,632,635,638,641,644,646,648,650,653,655,657,660,663,666],{"class":184,"style":185},[182,627,240],{"style":192},[182,629,303],{"style":188},[182,631,291],{"style":192},[182,633,634],{"style":196},"isResponseError",[182,636,637],{"style":188},"\u003C",[182,639,640],{"style":217},"GetPetByIdResponses",[182,642,643],{"style":188},">",[182,645,291],{"style":192},[182,647,82],{"style":196},[182,649,346],{"style":192},[182,651,652],{"style":188},"&& ",[182,654,82],{"style":196},[182,656,22],{"style":188},[182,658,659],{"style":192},"status ",[182,661,662],{"style":188},"=== ",[182,664,665],{"style":192},"404",[182,667,296],{"style":192},[182,669,670,673,675,677,679,681,683,685,687,689],{"class":184,"style":185},[182,671,672],{"style":192}," ",[182,674,322],{"style":196},[182,676,22],{"style":188},[182,678,82],{"style":217},[182,680,291],{"style":192},[182,682,82],{"style":196},[182,684,22],{"style":188},[182,686,65],{"style":192},[182,688,346],{"style":192},[182,690,691],{"style":349},"\u002F\u002F GetPetById404",[182,693,694,696],{"class":184,"style":185},[182,695,240],{"style":349},[182,697,355],{"style":192},[182,699,700],{"class":184,"style":185},[182,701,355],{"style":192},[491,703,705,706,709],{"as":704},"warning","The type argument is not checked at runtime, so keep the ",[15,707,708],{},"try"," around one operation.",[24,711,713],{"id":712},"return-the-error-instead","Return the error instead",[11,715,716,717,719,720,722,723,725,726,728],{},"With ",[15,718,21],{},", the call resolves for every status. ",[15,721,65],{}," is set on success and ",[15,724,82],{}," on failure, and a check on ",[15,727,86],{}," narrows both:",[173,730,732],{"language":175,"code":731,"class":177},"const result = await getPetById({ path: { petId: 1 }, throwOnError: false })\n\nif (result.error !== undefined) console.error(result.status, result.error)\nelse console.info(result.data)",[15,733,734,208,775,208,777,208,823],{"class":180},[182,735,736,738,741,743,745,747,749,751,753,755,757,759,761,763,765,767,769,772],{"class":184,"style":185},[182,737,243],{"style":188},[182,739,740],{"style":196},"result ",[182,742,253],{"style":188},[182,744,256],{"style":188},[182,746,259],{"style":217},[182,748,262],{"style":192},[182,750,265],{"style":192},[182,752,268],{"style":188},[182,754,193],{"style":192},[182,756,273],{"style":192},[182,758,268],{"style":188},[182,760,278],{"style":192},[182,762,355],{"style":192},[182,764,337],{"style":188},[182,766,33],{"style":192},[182,768,268],{"style":188},[182,770,771],{"style":192},"false ",[182,773,774],{"style":192},"})",[182,776],{"class":184,"style":185},[182,778,779,781,783,786,788,791,794,796,798,800,802,804,806,808,810,812,814,816,818,820],{"class":184,"style":185},[182,780,303],{"style":188},[182,782,291],{"style":192},[182,784,785],{"style":196},"result",[182,787,22],{"style":188},[182,789,790],{"style":192},"error ",[182,792,793],{"style":188},"!== ",[182,795,430],{"style":192},[182,797,346],{"style":192},[182,799,322],{"style":196},[182,801,22],{"style":188},[182,803,82],{"style":217},[182,805,291],{"style":192},[182,807,785],{"style":196},[182,809,22],{"style":188},[182,811,86],{"style":192},[182,813,337],{"style":188},[182,815,785],{"style":196},[182,817,22],{"style":188},[182,819,82],{"style":192},[182,821,822],{"style":192},")",[182,824,825,828,830,832,835,837,839,841,843],{"class":184,"style":185},[182,826,827],{"style":188},"else ",[182,829,322],{"style":196},[182,831,22],{"style":188},[182,833,834],{"style":217},"info",[182,836,291],{"style":192},[182,838,785],{"style":196},[182,840,22],{"style":188},[182,842,65],{"style":192},[182,844,822],{"style":192},[11,846,847,848,22],{},"See ",[140,849,851],{"href":850},"#empty-error-bodies-and-default-responses","Empty error bodies and default responses",[24,853,855],{"id":854},"set-the-generated-default","Set the generated default",[11,857,858,864,865,867,868,871],{},[140,859,861],{"href":860},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Foptions#throwonerrordefault",[15,862,863],{},"throwOnErrorDefault"," on the plugin sets what a call does when it leaves ",[15,866,33],{}," out. ",[15,869,870],{},"client.setConfig({ throwOnError })"," does not change it:",[173,873,875],{"language":175,"code":874,"class":177},"pluginAxios({ throwOnErrorDefault: false })\n\nconst list = await searchPets({ query: { status: 'available' } }) \u002F\u002F resolves with an error result\nconst pet = await getPetById({ path: { petId: 1 }, throwOnError: true }) \u002F\u002F throws",[15,876,877,208,892,208,894,208,930],{"class":180},[182,878,879,882,884,886,888,890],{"class":184,"style":185},[182,880,881],{"style":217},"pluginAxios",[182,883,262],{"style":192},[182,885,863],{"style":192},[182,887,268],{"style":188},[182,889,771],{"style":192},[182,891,774],{"style":192},[182,893],{"class":184,"style":185},[182,895,896,898,901,903,905,908,910,913,915,917,919,921,924,927],{"class":184,"style":185},[182,897,243],{"style":188},[182,899,900],{"style":196},"list ",[182,902,253],{"style":188},[182,904,256],{"style":188},[182,906,907],{"style":217},"searchPets",[182,909,262],{"style":192},[182,911,912],{"style":192},"query",[182,914,268],{"style":188},[182,916,193],{"style":192},[182,918,86],{"style":192},[182,920,268],{"style":188},[182,922,923],{"style":206},"'available' ",[182,925,926],{"style":192},"} }) ",[182,928,929],{"style":349},"\u002F\u002F resolves with an error result",[182,931,932,934,937,939,941,943,945,947,949,951,953,955,957,959,961,963,965,968,971],{"class":184,"style":185},[182,933,243],{"style":188},[182,935,936],{"style":196},"pet ",[182,938,253],{"style":188},[182,940,256],{"style":188},[182,942,259],{"style":217},[182,944,262],{"style":192},[182,946,265],{"style":192},[182,948,268],{"style":188},[182,950,193],{"style":192},[182,952,273],{"style":192},[182,954,268],{"style":188},[182,956,278],{"style":192},[182,958,355],{"style":192},[182,960,337],{"style":188},[182,962,33],{"style":192},[182,964,268],{"style":188},[182,966,967],{"style":192},"true ",[182,969,970],{"style":192},"}) ",[182,972,973],{"style":349},"\u002F\u002F throws",[24,975,977],{"id":976},"validation-failures","Validation failures",[11,979,716,980,985,986,988,989,34],{},[140,981,983],{"href":982},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Foptions#validator",[15,984,94],{}," on, a body that does not match its Zod schema throws a ",[15,987,100],{}," with the schema's ",[15,990,991],{},"issues",[173,993,995],{"language":175,"code":994,"class":177},"import { ValidationError } from '.\u002Fgen\u002F.kubb\u002FstandardSchema'\n\ntry {\n await getPetById({ path: { petId: 1 } })\n} catch (error) {\n if (error instanceof ValidationError) console.error(error.issues) \u002F\u002F [{ message, path }]\n}",[15,996,997,208,1013,208,1015,208,1021,208,1045,208,1057,208,1093],{"class":180},[182,998,999,1001,1003,1006,1008,1010],{"class":184,"style":185},[182,1000,189],{"style":188},[182,1002,193],{"style":192},[182,1004,1005],{"style":217},"ValidationError ",[182,1007,200],{"style":192},[182,1009,203],{"style":188},[182,1011,1012],{"style":206},"'.\u002Fgen\u002F.kubb\u002FstandardSchema'",[182,1014],{"class":184,"style":185},[182,1016,1017,1019],{"class":184,"style":185},[182,1018,232],{"style":188},[182,1020,235],{"style":192},[182,1022,1023,1025,1027,1029,1031,1033,1035,1037,1039,1041,1043],{"class":184,"style":185},[182,1024,240],{"style":192},[182,1026,256],{"style":188},[182,1028,259],{"style":217},[182,1030,262],{"style":192},[182,1032,265],{"style":192},[182,1034,268],{"style":188},[182,1036,193],{"style":192},[182,1038,273],{"style":192},[182,1040,268],{"style":188},[182,1042,278],{"style":192},[182,1044,281],{"style":192},[182,1046,1047,1049,1051,1053,1055],{"class":184,"style":185},[182,1048,200],{"style":192},[182,1050,288],{"style":188},[182,1052,291],{"style":192},[182,1054,82],{"style":196},[182,1056,296],{"style":192},[182,1058,1059,1061,1063,1065,1067,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090],{"class":184,"style":185},[182,1060,240],{"style":192},[182,1062,303],{"style":188},[182,1064,291],{"style":192},[182,1066,790],{"style":196},[182,1068,1069],{"style":188},"instanceof ",[182,1071,100],{"style":217},[182,1073,346],{"style":192},[182,1075,322],{"style":196},[182,1077,22],{"style":188},[182,1079,82],{"style":217},[182,1081,291],{"style":192},[182,1083,82],{"style":196},[182,1085,22],{"style":188},[182,1087,991],{"style":192},[182,1089,346],{"style":192},[182,1091,1092],{"style":349},"\u002F\u002F [{ message, path }]",[182,1094,1095],{"class":184,"style":185},[182,1096,355],{"style":192},[11,1098,1099,1101,1102,1105,1106,1109,1110,1113,1114,22],{},[15,1100,100],{}," was called ",[15,1103,1104],{},"ParseError",". The old name is still exported and deprecated, so ",[15,1107,1108],{},"instanceof ParseError"," keeps working. ",[15,1111,1112],{},"error.name"," is now ",[15,1115,1116],{},"'ValidationError'",[11,1118,1119,1120,1122,1123,337,1125,337,1128,1131,1132,1135,1136,1139,1140,1143],{},"A ",[15,1121,100],{}," from a response body also carries ",[15,1124,86],{},[15,1126,1127],{},"method",[15,1129,1130],{},"direction"," (",[15,1133,1134],{},"'response'"," or ",[15,1137,1138],{},"'error'","), and ",[15,1141,1142],{},"source",". So when a non-2xx body does not match its error schema, the status is still there:",[173,1145,1147],{"language":175,"code":1146,"class":177},"if (error instanceof ValidationError && error.status === 404) return null",[15,1148,1149],{"class":180},[182,1150,1151,1153,1155,1157,1159,1161,1163,1165,1167,1169,1171,1173,1175,1178],{"class":184,"style":185},[182,1152,303],{"style":188},[182,1154,291],{"style":192},[182,1156,790],{"style":196},[182,1158,1069],{"style":188},[182,1160,1005],{"style":217},[182,1162,652],{"style":188},[182,1164,82],{"style":196},[182,1166,22],{"style":188},[182,1168,659],{"style":192},[182,1170,662],{"style":188},[182,1172,665],{"style":192},[182,1174,346],{"style":192},[182,1176,1177],{"style":188},"return ",[182,1179,1180],{"style":192},"null",[11,1182,1183,1184,1187,1188,1191,1192,34],{},"To recover from a schema failure, pass ",[15,1185,1186],{},"onValidationError"," on the call or the client. Return ",[15,1189,1190],{},"{ value }"," to use that value, or nothing to throw the ",[15,1193,100],{},[173,1195,1197],{"language":175,"code":1196,"class":177},"client.setConfig({\n onValidationError: (error, { direction, source, value }) => {\n console.warn(direction, source, error.issues)\n return { value }\n },\n})",[15,1198,1199,208,1212,208,1246,208,1275,208,1287,208,1295],{"class":180},[182,1200,1201,1204,1206,1209],{"class":184,"style":185},[182,1202,1203],{"style":196},"client",[182,1205,22],{"style":188},[182,1207,1208],{"style":217},"setConfig",[182,1210,1211],{"style":192},"({",[182,1213,1214,1216,1218,1220,1222,1224,1226,1228,1230,1232,1234,1236,1239,1241,1244],{"class":184,"style":185},[182,1215,240],{"style":192},[182,1217,1186],{"style":192},[182,1219,268],{"style":188},[182,1221,291],{"style":192},[182,1223,82],{"style":196},[182,1225,337],{"style":188},[182,1227,193],{"style":192},[182,1229,1130],{"style":196},[182,1231,337],{"style":188},[182,1233,1142],{"style":196},[182,1235,337],{"style":188},[182,1237,1238],{"style":196},"value ",[182,1240,970],{"style":192},[182,1242,1243],{"style":188},"=> ",[182,1245,235],{"style":192},[182,1247,1248,1250,1252,1254,1257,1259,1261,1263,1265,1267,1269,1271,1273],{"class":184,"style":185},[182,1249,672],{"style":192},[182,1251,322],{"style":196},[182,1253,22],{"style":188},[182,1255,1256],{"style":217},"warn",[182,1258,291],{"style":192},[182,1260,1130],{"style":196},[182,1262,337],{"style":188},[182,1264,1142],{"style":196},[182,1266,337],{"style":188},[182,1268,82],{"style":196},[182,1270,22],{"style":188},[182,1272,991],{"style":192},[182,1274,822],{"style":192},[182,1276,1277,1279,1281,1283,1285],{"class":184,"style":185},[182,1278,672],{"style":192},[182,1280,1177],{"style":188},[182,1282,193],{"style":192},[182,1284,1238],{"style":196},[182,1286,355],{"style":192},[182,1288,1289,1292],{"class":184,"style":185},[182,1290,1291],{"style":192}," }",[182,1293,1294],{"style":188},",",[182,1296,1297],{"class":184,"style":185},[182,1298,774],{"style":192},[11,1300,1301,1302,1304,1305,1307,1308,76,1310,1312,1313,1315,1316,337,1318,1320,1321,1324,1325,1328,1329,22],{},"Invalid JSON does not reach the handler. When the handler returns ",[15,1303,1190],{}," for an error body, the call throws the ",[15,1306,17],{}," as usual, with that value as ",[15,1309,65],{},[15,1311,21],{},", the call resolves with that value as ",[15,1314,82],{}," instead. A ",[15,1317,1180],{},[15,1319,430],{},", or ",[15,1322,1323],{},"''"," value resolves as ",[15,1326,1327],{},"{ status, statusText }",", like an ",[140,1330,1331],{"href":850},"empty error body",[11,1333,1334,1335,22],{},"For which schema checks an error body, see ",[140,1336,1338],{"href":1337},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fserialization#error-body-validation","Error body validation",[24,1340,1342],{"id":1341},"turn-validation-off-at-runtime","Turn validation off at runtime",[11,1344,1345,1347,1348,1351],{},[15,1346,94],{}," decides at generation time which schemas a call carries. ",[15,1349,1350],{},"validate"," skips them at runtime, for example in production or in tests with partial fixtures:",[173,1353,1355],{"language":175,"code":1354,"class":177},"client.setConfig({ validate: import.meta.env.DEV })\nclient.setConfig({ validate: { response: false } }) \u002F\u002F skip one direction",[15,1356,1357,208,1391],{"class":180},[182,1358,1359,1361,1363,1365,1367,1369,1371,1374,1376,1379,1381,1384,1386,1389],{"class":184,"style":185},[182,1360,1203],{"style":196},[182,1362,22],{"style":188},[182,1364,1208],{"style":217},[182,1366,262],{"style":192},[182,1368,1350],{"style":192},[182,1370,268],{"style":188},[182,1372,1373],{"style":188},"import",[182,1375,22],{"style":188},[182,1377,1378],{"style":192},"meta",[182,1380,22],{"style":188},[182,1382,1383],{"style":192},"env",[182,1385,22],{"style":188},[182,1387,1388],{"style":192},"DEV ",[182,1390,774],{"style":192},[182,1392,1393,1395,1397,1399,1401,1403,1405,1407,1409,1411,1413,1415],{"class":184,"style":185},[182,1394,1203],{"style":196},[182,1396,22],{"style":188},[182,1398,1208],{"style":217},[182,1400,262],{"style":192},[182,1402,1350],{"style":192},[182,1404,268],{"style":188},[182,1406,193],{"style":192},[182,1408,464],{"style":192},[182,1410,268],{"style":188},[182,1412,771],{"style":192},[182,1414,926],{"style":192},[182,1416,1417],{"style":349},"\u002F\u002F skip one direction",[11,1419,1420,1421,1424,1425,268,1428,1430,1431,337,1434,1320,1436,1438,1439,1441],{},"The default is ",[15,1422,1423],{},"true",". The object form skips each direction set to ",[15,1426,1427],{},"false",[15,1429,452],{}," (the body), ",[15,1432,1433],{},"params",[15,1435,464],{},[15,1437,82],{},". A per-call ",[15,1440,1350],{}," overrides the client.",[24,1443,1445],{"id":1444},"less-common-cases","Less common cases",[1447,1448,539],"h3",{"id":1449},"status-ranges",[11,1451,1452,1453,1455,1456,1459],{},"When an operation declares a range key such as ",[15,1454,534],{},", the range covers its statuses that have no entry of their own, and ",[15,1457,1458],{},"default"," covers the rest.",[1447,1461,851],{"id":1462},"empty-error-bodies-and-default-responses",[11,1464,1465,1466,1468,1469,22],{},"When a failed call has an empty body, ",[15,1467,82],{}," is ",[15,1470,1327],{},[11,1472,1473,1474,1476,1477,1479,1480,83,1482,1484,1485,1487,1488,1491,1492,1495,1496,1498,1499,1502,1503,22],{},"When the operation declares a ",[15,1475,1458],{}," response, a check on ",[15,1478,86],{}," does not narrow ",[15,1481,65],{},[15,1483,82],{},", because a ",[15,1486,1458],{}," status can be any number. To get the success body with the default ",[15,1489,1490],{},"returnType: 'full'",", call ",[15,1493,1494],{},".unwrap()",", which turns ",[15,1497,82],{}," into a rejection. With ",[15,1500,1501],{},"returnType: 'data'",", the call returns a plain promise without ",[15,1504,1494],{},[1447,1506,1508,1509,1511],{"id":1507},"where-the-throwonerror-default-comes-from","Where the ",[15,1510,33],{}," default comes from",[11,1513,1514,1515,1517,1518,1520,1521,1525,1526,1529],{},"When you set ",[15,1516,870],{},", generated calls ignore it, because each generated function passes its own value: the call's ",[15,1519,33],{},", or else ",[140,1522,1523],{"href":860},[15,1524,863],{},". That value is also the default of the function's ",[15,1527,1528],{},"ThrowOnError"," type parameter.",[1447,1531,1533,1534],{"id":1532},"read-headers-with-returntype-data","Read headers with ",[15,1535,1501],{},[11,1537,1538,1539,1544,1545,1548,1549,1551,1552,1555,1556,22],{},"When the plugin sets ",[140,1540,1542],{"href":1541},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Foptions#returntype",[15,1543,1501],{},", a call resolves to the success body alone. To read a header such as ",[15,1546,1547],{},"ETag",", pass ",[15,1550,21],{}," and call ",[15,1553,1554],{},"result.headers.get('etag')",". For a stream call, see ",[140,1557,1559],{"href":1558},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fserver-sent-events#event-ids-when-you-resume","Event IDs when you resume",[11,1561,1562,1563,1566,1567,1570,1571,22],{},"The query plugins and ",[15,1564,1565],{},"@kubb\u002Fplugin-mcp"," read ",[15,1568,1569],{},"returnType"," too, including a per-operation value from ",[140,1572,1574],{"href":1573},"https:\u002F\u002Fkubb.dev\u002Fdocs\u002F5.x\u002Freference\u002Fplugin-options#override",[15,1575,1576],{},"override",{"title":1578,"searchDepth":1579,"depth":1579,"links":1580},"",5,[1581,1583,1584,1585,1586,1587,1588,1589],{"id":26,"depth":1582,"text":27},2,{"id":156,"depth":1582,"text":157},{"id":515,"depth":1582,"text":516},{"id":712,"depth":1582,"text":713},{"id":854,"depth":1582,"text":855},{"id":976,"depth":1582,"text":977},{"id":1341,"depth":1582,"text":1342},{"id":1444,"depth":1582,"text":1445,"children":1590},[1591,1593,1594,1596],{"id":1449,"depth":1592,"text":539},3,{"id":1462,"depth":1592,"text":851},{"id":1507,"depth":1592,"text":1595},"Where the throwOnError default comes from",{"id":1532,"depth":1592,"text":1597},"Read headers with returnType: 'data'","\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Ferror-handling",1795727683283,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]