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

Merge pull request #2970 from hey-api/copilot/fix-fetch-client-aborterror

Fix fetch client to intercept AbortError and network exceptions

authored by

Lubos and committed by
GitHub
db289265 c2a58894

+4996 -144
+5
.changeset/six-beds-tickle.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + **client-fetch**: intercept AbortError
+34 -1
examples/openapi-ts-fastify/src/client/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
examples/openapi-ts-fetch/src/client/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
examples/openapi-ts-openai/src/client/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+29 -1
examples/openapi-ts-pinia-colada/src/client/client/client.gen.ts
··· 85 85 // fetch must be assigned here, otherwise it would throw the error: 86 86 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 87 87 const _fetch = opts.fetch! 88 - let response = await _fetch(request) 88 + let response: Response 89 + 90 + try { 91 + response = await _fetch(request) 92 + } catch (error) { 93 + // Handle fetch exceptions (AbortError, network errors, etc.) 94 + let finalError = error 95 + 96 + for (const fn of interceptors.error.fns) { 97 + if (fn) { 98 + finalError = (await fn(error, undefined as any, request, opts)) as unknown 99 + } 100 + } 101 + 102 + finalError = finalError || ({} as unknown) 103 + 104 + if (opts.throwOnError) { 105 + throw finalError 106 + } 107 + 108 + // Return error response 109 + return opts.responseStyle === 'data' 110 + ? undefined 111 + : { 112 + error: finalError, 113 + request, 114 + response: undefined as any 115 + } 116 + } 89 117 90 118 for (const fn of interceptors.response.fns) { 91 119 if (fn) {
+34 -1
examples/openapi-ts-tanstack-react-query/src/client/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
examples/openapi-ts-tanstack-svelte-query/src/client/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+29 -1
examples/openapi-ts-tanstack-vue-query/src/client/client/client.gen.ts
··· 85 85 // fetch must be assigned here, otherwise it would throw the error: 86 86 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 87 87 const _fetch = opts.fetch! 88 - let response = await _fetch(request) 88 + let response: Response 89 + 90 + try { 91 + response = await _fetch(request) 92 + } catch (error) { 93 + // Handle fetch exceptions (AbortError, network errors, etc.) 94 + let finalError = error 95 + 96 + for (const fn of interceptors.error.fns) { 97 + if (fn) { 98 + finalError = (await fn(error, undefined as any, request, opts)) as unknown 99 + } 100 + } 101 + 102 + finalError = finalError || ({} as unknown) 103 + 104 + if (opts.throwOnError) { 105 + throw finalError 106 + } 107 + 108 + // Return error response 109 + return opts.responseStyle === 'data' 110 + ? undefined 111 + : { 112 + error: finalError, 113 + request, 114 + response: undefined as any 115 + } 116 + } 89 117 90 118 for (const fn of interceptors.response.fns) { 91 119 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-recursive/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/import-file-extension-ts/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-recursive/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/class/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/flat/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/sdks/__snapshots__/method-class-conflict/instance/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/sdks/__snapshots__/opencode/flat/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+34 -1
packages/openapi-ts-tests/sdks/__snapshots__/opencode/grouped/client/client.gen.ts
··· 95 95 // fetch must be assigned here, otherwise it would throw the error: 96 96 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 97 const _fetch = opts.fetch!; 98 - let response = await _fetch(request); 98 + let response: Response; 99 + 100 + try { 101 + response = await _fetch(request); 102 + } catch (error) { 103 + // Handle fetch exceptions (AbortError, network errors, etc.) 104 + let finalError = error; 105 + 106 + for (const fn of interceptors.error.fns) { 107 + if (fn) { 108 + finalError = (await fn( 109 + error, 110 + undefined as any, 111 + request, 112 + opts, 113 + )) as unknown; 114 + } 115 + } 116 + 117 + finalError = finalError || ({} as unknown); 118 + 119 + if (opts.throwOnError) { 120 + throw finalError; 121 + } 122 + 123 + // Return error response 124 + return opts.responseStyle === 'data' 125 + ? undefined 126 + : { 127 + error: finalError, 128 + request, 129 + response: undefined as any, 130 + }; 131 + } 99 132 100 133 for (const fn of interceptors.response.fns) { 101 134 if (fn) {
+105
packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts
··· 406 406 }, 407 407 ); 408 408 }); 409 + 410 + describe('error interceptor for fetch exceptions', () => { 411 + it('intercepts AbortError when fetch is aborted', async () => { 412 + const client = createClient({ baseUrl: 'https://example.com' }); 413 + 414 + const abortError = new DOMException( 415 + 'The operation was aborted', 416 + 'AbortError', 417 + ); 418 + const mockFetch: MockFetch = vi.fn().mockRejectedValue(abortError); 419 + 420 + const mockErrorInterceptor = vi.fn().mockImplementation((error) => { 421 + expect(error).toBe(abortError); 422 + return { message: 'Request was aborted', type: 'abort' }; 423 + }); 424 + 425 + const interceptorId = client.interceptors.error.use(mockErrorInterceptor); 426 + 427 + const result = await client.get({ 428 + fetch: mockFetch, 429 + url: '/test', 430 + }); 431 + 432 + expect(mockErrorInterceptor).toHaveBeenCalledOnce(); 433 + expect(result.error).toEqual({ 434 + message: 'Request was aborted', 435 + type: 'abort', 436 + }); 437 + 438 + client.interceptors.error.eject(interceptorId); 439 + }); 440 + 441 + it('intercepts network errors', async () => { 442 + const client = createClient({ baseUrl: 'https://example.com' }); 443 + 444 + const networkError = new TypeError('Failed to fetch'); 445 + const mockFetch: MockFetch = vi.fn().mockRejectedValue(networkError); 446 + 447 + const mockErrorInterceptor = vi.fn().mockImplementation((error) => { 448 + expect(error).toBe(networkError); 449 + return { message: 'Network error occurred', type: 'network' }; 450 + }); 451 + 452 + const interceptorId = client.interceptors.error.use(mockErrorInterceptor); 453 + 454 + const result = await client.get({ 455 + fetch: mockFetch, 456 + url: '/test', 457 + }); 458 + 459 + expect(mockErrorInterceptor).toHaveBeenCalledOnce(); 460 + expect(result.error).toEqual({ 461 + message: 'Network error occurred', 462 + type: 'network', 463 + }); 464 + 465 + client.interceptors.error.eject(interceptorId); 466 + }); 467 + 468 + it('throws AbortError when throwOnError is true', async () => { 469 + const client = createClient({ baseUrl: 'https://example.com' }); 470 + 471 + const abortError = new DOMException( 472 + 'The operation was aborted', 473 + 'AbortError', 474 + ); 475 + const mockFetch: MockFetch = vi.fn().mockRejectedValue(abortError); 476 + 477 + const mockErrorInterceptor = vi.fn().mockImplementation(() => ({ 478 + message: 'Request was aborted', 479 + type: 'abort', 480 + })); 481 + 482 + const interceptorId = client.interceptors.error.use(mockErrorInterceptor); 483 + 484 + await expect( 485 + client.get({ 486 + fetch: mockFetch, 487 + throwOnError: true, 488 + url: '/test', 489 + }), 490 + ).rejects.toEqual({ message: 'Request was aborted', type: 'abort' }); 491 + 492 + expect(mockErrorInterceptor).toHaveBeenCalledOnce(); 493 + 494 + client.interceptors.error.eject(interceptorId); 495 + }); 496 + 497 + it('handles fetch exceptions without error interceptor', async () => { 498 + const client = createClient({ baseUrl: 'https://example.com' }); 499 + 500 + const abortError = new DOMException( 501 + 'The operation was aborted', 502 + 'AbortError', 503 + ); 504 + const mockFetch: MockFetch = vi.fn().mockRejectedValue(abortError); 505 + 506 + const result = await client.get({ 507 + fetch: mockFetch, 508 + url: '/test', 509 + }); 510 + 511 + expect(result.error).toBe(abortError); 512 + }); 513 + });
+34 -1
packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts
··· 93 93 // fetch must be assigned here, otherwise it would throw the error: 94 94 // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 95 95 const _fetch = opts.fetch!; 96 - let response = await _fetch(request); 96 + let response: Response; 97 + 98 + try { 99 + response = await _fetch(request); 100 + } catch (error) { 101 + // Handle fetch exceptions (AbortError, network errors, etc.) 102 + let finalError = error; 103 + 104 + for (const fn of interceptors.error.fns) { 105 + if (fn) { 106 + finalError = (await fn( 107 + error, 108 + undefined as any, 109 + request, 110 + opts, 111 + )) as unknown; 112 + } 113 + } 114 + 115 + finalError = finalError || ({} as unknown); 116 + 117 + if (opts.throwOnError) { 118 + throw finalError; 119 + } 120 + 121 + // Return error response 122 + return opts.responseStyle === 'data' 123 + ? undefined 124 + : { 125 + error: finalError, 126 + request, 127 + response: undefined as any, 128 + }; 129 + } 97 130 98 131 for (const fn of interceptors.response.fns) { 99 132 if (fn) {