fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: surface actual error message when spec fetch fails

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>

+8 -3
+4 -1
packages/openapi-ts/src/createClient.ts
··· 66 66 // if in watch mode, subsequent errors won't throw to gracefully handle 67 67 // cases where server might be reloading 68 68 if (error && !_watches) { 69 - throw new Error(`Request failed with status ${response.status}: ${response.statusText}`); 69 + const text = await response.text().catch(() => ''); 70 + throw new Error( 71 + `Request failed with status ${response.status}: ${text || response.statusText}`, 72 + ); 70 73 } 71 74 72 75 return { arrayBuffer, resolvedInput };
+4 -2
packages/shared/src/getSpec.ts
··· 105 105 106 106 response = request.response; 107 107 } catch (error) { 108 + const message = error instanceof Error ? error.message : String(error); 108 109 return { 109 110 error: 'not-ok', 110 - response: new Response(error instanceof Error ? error.message : String(error)), 111 + response: new Response(message, { status: 500 }), 111 112 }; 112 113 } 113 114 ··· 181 182 182 183 response = request.response; 183 184 } catch (error) { 185 + const message = error instanceof Error ? error.message : String(error); 184 186 return { 185 187 error: 'not-ok', 186 - response: new Response(error instanceof Error ? error.message : String(error)), 188 + response: new Response(message, { status: 500 }), 187 189 }; 188 190 } 189 191