[{"data":1,"prerenderedAt":1501},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ferror-handling":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1500,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ferror-handling.md",{},"Handle errors",{"type":8,"value":9,"toc":1479},"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,1124,1232,1239,1243,1252,1318,1343,1347,1351,1361,1364,1373,1407,1414,1432,1438,1462],[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],{},"ParseError",[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 { ParseError } from '.\u002Fgen\u002F.kubb\u002FstandardSchema'\n\ntry {\n  await getPetById({ path: { petId: 1 } })\n} catch (error) {\n  if (error instanceof ParseError) 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},"ParseError ",[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,1114,1117,1118,1121,1122,34],{},"To recover, pass ",[15,1115,1116],{},"onValidationError"," on the call or the client. Return ",[15,1119,1120],{},"{ value }"," to use that value, or nothing to throw the ",[15,1123,100],{},[187,1125,1127],{"language":189,"code":1126,"class":191},"client.setConfig({\n  onValidationError: (error, { direction, source, value }) => {\n    console.warn(direction, source, error.issues)\n    return { value }\n  },\n})",[15,1128,1129,222,1142,222,1178,222,1207,222,1220,222,1228],{"class":194},[196,1130,1131,1134,1136,1139],{"class":198,"style":199},[196,1132,1133],{"style":210},"client",[196,1135,22],{"style":202},[196,1137,1138],{"style":231},"setConfig",[196,1140,1141],{"style":206},"({",[196,1143,1144,1146,1148,1150,1152,1154,1156,1158,1161,1163,1166,1168,1171,1173,1176],{"class":198,"style":199},[196,1145,254],{"style":206},[196,1147,1116],{"style":206},[196,1149,282],{"style":202},[196,1151,305],{"style":206},[196,1153,82],{"style":210},[196,1155,351],{"style":202},[196,1157,207],{"style":206},[196,1159,1160],{"style":210},"direction",[196,1162,351],{"style":202},[196,1164,1165],{"style":210},"source",[196,1167,351],{"style":202},[196,1169,1170],{"style":210},"value ",[196,1172,984],{"style":206},[196,1174,1175],{"style":202},"=> ",[196,1177,249],{"style":206},[196,1179,1180,1182,1184,1186,1189,1191,1193,1195,1197,1199,1201,1203,1205],{"class":198,"style":199},[196,1181,686],{"style":206},[196,1183,336],{"style":210},[196,1185,22],{"style":202},[196,1187,1188],{"style":231},"warn",[196,1190,305],{"style":206},[196,1192,1160],{"style":210},[196,1194,351],{"style":202},[196,1196,1165],{"style":210},[196,1198,351],{"style":202},[196,1200,82],{"style":210},[196,1202,22],{"style":202},[196,1204,1005],{"style":206},[196,1206,836],{"style":206},[196,1208,1209,1211,1214,1216,1218],{"class":198,"style":199},[196,1210,686],{"style":206},[196,1212,1213],{"style":202},"return ",[196,1215,207],{"style":206},[196,1217,1170],{"style":210},[196,1219,369],{"style":206},[196,1221,1222,1225],{"class":198,"style":199},[196,1223,1224],{"style":206},"  }",[196,1226,1227],{"style":202},",",[196,1229,1230],{"class":198,"style":199},[196,1231,788],{"style":206},[11,1233,1234,1235,22],{},"For which schema checks an error body, see ",[154,1236,1238],{"href":1237},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fserialization#error-body-validation","Error body validation",[24,1240,1242],{"id":1241},"turn-validation-off-at-runtime","Turn validation off at runtime",[11,1244,1245,1247,1248,1251],{},[15,1246,94],{}," decides at generation time which schemas a call carries. ",[15,1249,1250],{},"validate"," skips them at runtime, for example in production or in tests with partial fixtures:",[187,1253,1255],{"language":189,"code":1254,"class":191},"client.setConfig({ validate: import.meta.env.DEV })\nclient.setConfig({ validate: { response: false } }) \u002F\u002F skip one direction",[15,1256,1257,222,1291],{"class":194},[196,1258,1259,1261,1263,1265,1267,1269,1271,1274,1276,1279,1281,1284,1286,1289],{"class":198,"style":199},[196,1260,1133],{"style":210},[196,1262,22],{"style":202},[196,1264,1138],{"style":231},[196,1266,276],{"style":206},[196,1268,1250],{"style":206},[196,1270,282],{"style":202},[196,1272,1273],{"style":202},"import",[196,1275,22],{"style":202},[196,1277,1278],{"style":206},"meta",[196,1280,22],{"style":202},[196,1282,1283],{"style":206},"env",[196,1285,22],{"style":202},[196,1287,1288],{"style":206},"DEV ",[196,1290,788],{"style":206},[196,1292,1293,1295,1297,1299,1301,1303,1305,1307,1309,1311,1313,1315],{"class":198,"style":199},[196,1294,1133],{"style":210},[196,1296,22],{"style":202},[196,1298,1138],{"style":231},[196,1300,276],{"style":206},[196,1302,1250],{"style":206},[196,1304,282],{"style":202},[196,1306,207],{"style":206},[196,1308,478],{"style":206},[196,1310,282],{"style":202},[196,1312,785],{"style":206},[196,1314,940],{"style":206},[196,1316,1317],{"style":363},"\u002F\u002F skip one direction",[11,1319,1320,1321,1324,1325,282,1328,1330,1331,351,1334,1336,1337,1339,1340,1342],{},"The default is ",[15,1322,1323],{},"true",". The object form skips each direction set to ",[15,1326,1327],{},"false",[15,1329,466],{}," (the body), ",[15,1332,1333],{},"params",[15,1335,478],{},", or ",[15,1338,82],{},". A per-call ",[15,1341,1250],{}," overrides the client.",[24,1344,1346],{"id":1345},"less-common-cases","Less common cases",[1348,1349,553],"h3",{"id":1350},"status-ranges",[11,1352,1353,1354,1356,1357,1360],{},"When an operation declares a range key such as ",[15,1355,548],{},", the range covers its statuses that have no entry of their own, and ",[15,1358,1359],{},"default"," covers the rest.",[1348,1362,865],{"id":1363},"empty-error-bodies-and-default-responses",[11,1365,1366,1367,1369,1370,22],{},"When a failed call has an empty body, ",[15,1368,82],{}," is ",[15,1371,1372],{},"{ status, statusText }",[11,1374,1375,1376,1378,1379,1381,1382,83,1384,1386,1387,1389,1390,1393,1394,1397,1398,1400,1401,1404,1405,22],{},"When the operation declares a ",[15,1377,1359],{}," response, a check on ",[15,1380,86],{}," does not narrow ",[15,1383,65],{},[15,1385,82],{},", because a ",[15,1388,1359],{}," status can be any number. To get the success body with the default ",[15,1391,1392],{},"returnType: 'full'",", call ",[15,1395,1396],{},".unwrap()",", which turns ",[15,1399,82],{}," into a rejection. With ",[15,1402,1403],{},"returnType: 'data'",", the call returns a plain promise without ",[15,1406,1396],{},[1348,1408,1410,1411,1413],{"id":1409},"where-the-throwonerror-default-comes-from","Where the ",[15,1412,33],{}," default comes from",[11,1415,1416,1417,1419,1420,1422,1423,1427,1428,1431],{},"When you set ",[15,1418,884],{},", generated calls ignore it, because each generated function passes its own value: the call's ",[15,1421,33],{},", or else ",[154,1424,1425],{"href":874},[15,1426,877],{},". That value is also the default of the function's ",[15,1429,1430],{},"ThrowOnError"," type parameter.",[1348,1433,1435,1436],{"id":1434},"read-headers-with-returntype-data","Read headers with ",[15,1437,1403],{},[11,1439,1440,1441,1446,1447,1450,1451,1453,1454,1457,1458,22],{},"When the plugin sets ",[154,1442,1444],{"href":1443},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Foptions#returntype",[15,1445,1403],{},", a call resolves to the success body alone. To read a header such as ",[15,1448,1449],{},"ETag",", pass ",[15,1452,21],{}," and call ",[15,1455,1456],{},"result.headers.get('etag')",". For a stream call, see ",[154,1459,1461],{"href":1460},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fserver-sent-events#event-ids-when-you-resume","Event IDs when you resume",[11,1463,1464,1465,1468,1469,1472,1473,22],{},"The query plugins and ",[15,1466,1467],{},"@kubb\u002Fplugin-mcp"," read ",[15,1470,1471],{},"returnType"," too, including a per-operation value from ",[154,1474,1476],{"href":1475},"https:\u002F\u002Fkubb.dev\u002Fdocs\u002F5.x\u002Freference\u002Fplugin-options#override",[15,1477,1478],{},"override",{"title":1480,"searchDepth":1481,"depth":1481,"links":1482},"",5,[1483,1485,1486,1487,1488,1489,1490,1491],{"id":26,"depth":1484,"text":27},2,{"id":170,"depth":1484,"text":171},{"id":529,"depth":1484,"text":530},{"id":726,"depth":1484,"text":727},{"id":868,"depth":1484,"text":869},{"id":990,"depth":1484,"text":991},{"id":1241,"depth":1484,"text":1242},{"id":1345,"depth":1484,"text":1346,"children":1492},[1493,1495,1496,1498],{"id":1350,"depth":1494,"text":553},3,{"id":1363,"depth":1494,"text":865},{"id":1409,"depth":1494,"text":1497},"Where the throwOnError default comes from",{"id":1434,"depth":1494,"text":1499},"Read headers with returnType: 'data'","\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ferror-handling",1795015653647]