From 86077b3af8ea93bfc0a9c1b1ec5c68f47791a41d Mon Sep 17 00:00:00 2001 From: Jordan Shatford Date: Sat, 30 Mar 2024 15:30:40 +1100 Subject: [PATCH] feat(client): support all http error codes --- .changeset/neat-ads-fry.md | 5 +++ .../core/functions/catchErrorCodes.hbs | 33 +++++++++++++++++++ test/__snapshots__/v2/core/request.ts.snap | 33 +++++++++++++++++++ test/__snapshots__/v3/core/request.ts.snap | 33 +++++++++++++++++++ .../v3_angular/core/request.ts.snap | 33 +++++++++++++++++++ .../v3_axios/core/request.ts.snap | 33 +++++++++++++++++++ .../v3_client/core/request.ts.snap | 33 +++++++++++++++++++ .../v3_enums_typescript/core/request.ts.snap | 33 +++++++++++++++++++ .../v3_node/core/request.ts.snap | 33 +++++++++++++++++++ .../v3_options/core/request.ts.snap | 33 +++++++++++++++++++ .../__snapshots__/v3_xhr/core/request.ts.snap | 33 +++++++++++++++++++ test/e2e/client.angular.spec.ts | 14 ++++---- test/e2e/client.axios.spec.ts | 14 ++++---- test/e2e/client.fetch.spec.ts | 14 ++++---- test/e2e/client.node.spec.ts | 14 ++++---- test/e2e/client.xhr.spec.ts | 14 ++++---- test/e2e/v3.angular.spec.ts | 15 ++++----- test/e2e/v3.axios.spec.ts | 14 ++++---- test/e2e/v3.fetch.spec.ts | 14 ++++---- test/e2e/v3.node.spec.ts | 14 ++++---- test/e2e/v3.xhr.spec.ts | 14 ++++---- 21 files changed, 405 insertions(+), 71 deletions(-) create mode 100644 .changeset/neat-ads-fry.md diff --git a/.changeset/neat-ads-fry.md b/.changeset/neat-ads-fry.md new file mode 100644 index 000000000..52d004e24 --- /dev/null +++ b/.changeset/neat-ads-fry.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": minor +--- + +Support all HTTP error codes diff --git a/src/templates/core/functions/catchErrorCodes.hbs b/src/templates/core/functions/catchErrorCodes.hbs index 42f69d071..f686bc096 100644 --- a/src/templates/core/functions/catchErrorCodes.hbs +++ b/src/templates/core/functions/catchErrorCodes.hbs @@ -4,11 +4,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, } diff --git a/test/__snapshots__/v2/core/request.ts.snap b/test/__snapshots__/v2/core/request.ts.snap index bf88d79e9..b7e9802f1 100644 --- a/test/__snapshots__/v2/core/request.ts.snap +++ b/test/__snapshots__/v2/core/request.ts.snap @@ -236,11 +236,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3/core/request.ts.snap b/test/__snapshots__/v3/core/request.ts.snap index bf88d79e9..b7e9802f1 100644 --- a/test/__snapshots__/v3/core/request.ts.snap +++ b/test/__snapshots__/v3/core/request.ts.snap @@ -236,11 +236,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3_angular/core/request.ts.snap b/test/__snapshots__/v3_angular/core/request.ts.snap index b07e37671..f2feb7408 100644 --- a/test/__snapshots__/v3_angular/core/request.ts.snap +++ b/test/__snapshots__/v3_angular/core/request.ts.snap @@ -211,11 +211,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3_axios/core/request.ts.snap b/test/__snapshots__/v3_axios/core/request.ts.snap index b183a405c..2143ba487 100644 --- a/test/__snapshots__/v3_axios/core/request.ts.snap +++ b/test/__snapshots__/v3_axios/core/request.ts.snap @@ -235,11 +235,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3_client/core/request.ts.snap b/test/__snapshots__/v3_client/core/request.ts.snap index bf88d79e9..b7e9802f1 100644 --- a/test/__snapshots__/v3_client/core/request.ts.snap +++ b/test/__snapshots__/v3_client/core/request.ts.snap @@ -236,11 +236,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3_enums_typescript/core/request.ts.snap b/test/__snapshots__/v3_enums_typescript/core/request.ts.snap index bf88d79e9..b7e9802f1 100644 --- a/test/__snapshots__/v3_enums_typescript/core/request.ts.snap +++ b/test/__snapshots__/v3_enums_typescript/core/request.ts.snap @@ -236,11 +236,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3_node/core/request.ts.snap b/test/__snapshots__/v3_node/core/request.ts.snap index 327d93752..09084667e 100644 --- a/test/__snapshots__/v3_node/core/request.ts.snap +++ b/test/__snapshots__/v3_node/core/request.ts.snap @@ -235,11 +235,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3_options/core/request.ts.snap b/test/__snapshots__/v3_options/core/request.ts.snap index bf88d79e9..b7e9802f1 100644 --- a/test/__snapshots__/v3_options/core/request.ts.snap +++ b/test/__snapshots__/v3_options/core/request.ts.snap @@ -236,11 +236,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/__snapshots__/v3_xhr/core/request.ts.snap b/test/__snapshots__/v3_xhr/core/request.ts.snap index 4bf6110b4..c24d41264 100644 --- a/test/__snapshots__/v3_xhr/core/request.ts.snap +++ b/test/__snapshots__/v3_xhr/core/request.ts.snap @@ -237,11 +237,44 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): const errors: Record = { 400: 'Bad Request', 401: 'Unauthorized', + 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', + 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', ...options.errors, }; diff --git a/test/e2e/client.angular.spec.ts b/test/e2e/client.angular.spec.ts index d24cdb6f1..b67cc83fe 100644 --- a/test/e2e/client.angular.spec.ts +++ b/test/e2e/client.angular.spec.ts @@ -139,13 +139,13 @@ describe('client.angular', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { const error = await browser.evaluate( async () => await new Promise(resolve => { // @ts-ignore const { ErrorService } = window.api; - ErrorService.testErrorCode(409).subscribe({ + ErrorService.testErrorCode(599).subscribe({ error: (e: unknown) => { resolve( JSON.stringify({ @@ -172,12 +172,12 @@ describe('client.angular', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/client.axios.spec.ts b/test/e2e/client.axios.spec.ts index 067e5b52d..e67831c2d 100644 --- a/test/e2e/client.axios.spec.ts +++ b/test/e2e/client.axios.spec.ts @@ -121,12 +121,12 @@ describe('client.axios', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { let error; try { const { ApiClient } = await import('./generated/client/axios/index.js'); const client = new ApiClient(); - await client.error.testErrorCode(409); + await client.error.testErrorCode(599); } catch (err) { error = JSON.stringify({ name: err.name, @@ -141,12 +141,12 @@ describe('client.axios', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/client.fetch.spec.ts b/test/e2e/client.fetch.spec.ts index 00c951c0c..4f50490be 100644 --- a/test/e2e/client.fetch.spec.ts +++ b/test/e2e/client.fetch.spec.ts @@ -144,13 +144,13 @@ describe('client.fetch', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { const error = await browser.evaluate(async () => { try { // @ts-ignore const { ApiClient } = window.api; const client = new ApiClient(); - await client.error.testErrorCode(409); + await client.error.testErrorCode(599); } catch (error) { return JSON.stringify({ name: error.name, @@ -167,12 +167,12 @@ describe('client.fetch', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/client.node.spec.ts b/test/e2e/client.node.spec.ts index 3c065968c..95b7c3203 100644 --- a/test/e2e/client.node.spec.ts +++ b/test/e2e/client.node.spec.ts @@ -121,12 +121,12 @@ describe('client.node', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { let error; try { const { ApiClient } = await import('./generated/client/node/index.js'); const client = new ApiClient(); - await client.error.testErrorCode(409); + await client.error.testErrorCode(599); } catch (err) { error = JSON.stringify({ name: err.name, @@ -141,12 +141,12 @@ describe('client.node', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/client.xhr.spec.ts b/test/e2e/client.xhr.spec.ts index 4af307912..cb610c78d 100644 --- a/test/e2e/client.xhr.spec.ts +++ b/test/e2e/client.xhr.spec.ts @@ -143,13 +143,13 @@ describe('client.xhr', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { const error = await browser.evaluate(async () => { try { // @ts-ignore const { ApiClient } = window.api; const client = new ApiClient(); - await client.error.testErrorCode(409); + await client.error.testErrorCode(599); } catch (error) { return JSON.stringify({ name: error.name, @@ -166,12 +166,12 @@ describe('client.xhr', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/v3.angular.spec.ts b/test/e2e/v3.angular.spec.ts index f438ba4b6..1f9a12bdd 100644 --- a/test/e2e/v3.angular.spec.ts +++ b/test/e2e/v3.angular.spec.ts @@ -131,15 +131,14 @@ describe('v3.angular', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { const error = await browser.evaluate(async () => { // @ts-ignore const { ErrorService } = window.api; - ErrorService.testErrorCode(409).subscribe(console.log, console.log); try { await new Promise((resolve, reject) => { // const { ErrorService } = window.api; - ErrorService.testErrorCode(409).subscribe(resolve, reject); + ErrorService.testErrorCode(599).subscribe(resolve, reject); }); } catch (error) { return JSON.stringify({ @@ -157,12 +156,12 @@ describe('v3.angular', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/v3.axios.spec.ts b/test/e2e/v3.axios.spec.ts index 752a529cd..b8388367c 100644 --- a/test/e2e/v3.axios.spec.ts +++ b/test/e2e/v3.axios.spec.ts @@ -115,12 +115,12 @@ describe('v3.axios', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { let error; try { const { ErrorService } = await import('./generated/v3/axios/index.js'); // @ts-ignore - await ErrorService.testErrorCode(409); + await ErrorService.testErrorCode(599); } catch (err) { error = JSON.stringify({ name: err.name, @@ -135,12 +135,12 @@ describe('v3.axios', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/v3.fetch.spec.ts b/test/e2e/v3.fetch.spec.ts index c0cd8d11e..f548c38e5 100644 --- a/test/e2e/v3.fetch.spec.ts +++ b/test/e2e/v3.fetch.spec.ts @@ -145,12 +145,12 @@ describe('v3.fetch', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { const error = await browser.evaluate(async () => { try { // @ts-ignore const { ErrorService } = window.api; - await ErrorService.testErrorCode(409); + await ErrorService.testErrorCode(599); } catch (error) { return JSON.stringify({ name: error.name, @@ -167,12 +167,12 @@ describe('v3.fetch', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/v3.node.spec.ts b/test/e2e/v3.node.spec.ts index 23d26e549..c6a6048a7 100644 --- a/test/e2e/v3.node.spec.ts +++ b/test/e2e/v3.node.spec.ts @@ -121,12 +121,12 @@ describe('v3.node', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { let error; try { const { ErrorService } = await import('./generated/v3/node/index.js'); // @ts-ignore - await ErrorService.testErrorCode(409); + await ErrorService.testErrorCode(599); } catch (err) { error = JSON.stringify({ name: err.name, @@ -141,12 +141,12 @@ describe('v3.node', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, }) diff --git a/test/e2e/v3.xhr.spec.ts b/test/e2e/v3.xhr.spec.ts index 526158c0b..929bc85db 100644 --- a/test/e2e/v3.xhr.spec.ts +++ b/test/e2e/v3.xhr.spec.ts @@ -135,12 +135,12 @@ describe('v3.xhr', () => { ); }); - it('should throw unknown error (409)', async () => { + it('should throw unknown error (599)', async () => { const error = await browser.evaluate(async () => { try { // @ts-ignore const { ErrorService } = window.api; - await ErrorService.testErrorCode(409); + await ErrorService.testErrorCode(599); } catch (error) { return JSON.stringify({ name: error.name, @@ -157,12 +157,12 @@ describe('v3.xhr', () => { JSON.stringify({ name: 'ApiError', message: - 'Generic Error: status: 409; status text: Conflict; body: {\n "status": 409,\n "message": "hello world"\n}', - url: 'http://localhost:3000/base/api/v1.0/error?status=409', - status: 409, - statusText: 'Conflict', + 'Generic Error: status: 599; status text: unknown; body: {\n "status": 599,\n "message": "hello world"\n}', + url: 'http://localhost:3000/base/api/v1.0/error?status=599', + status: 599, + statusText: 'unknown', body: { - status: 409, + status: 599, message: 'hello world', }, })