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