From 99b4a07747641488f835f7281b4166a20fdd80d6 Mon Sep 17 00:00:00 2001 From: mo4islona Date: Thu, 26 Oct 2023 03:42:35 +0400 Subject: [PATCH 1/3] fix: improve api error handling --- src/api/api.ts | 15 +++++++++++---- src/command.ts | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/api/api.ts b/src/api/api.ts index d23c361..294b639 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -60,7 +60,7 @@ export async function api({ const sanitizedQuery = pickBy(query, (v) => v); const queryString = Object.keys(sanitizedQuery).length ? `?${qs.stringify(sanitizedQuery)}` : ''; - const url = `${config.apiUrl}${path}${queryString}`; + const url = !path.startsWith('https') ? `${config.apiUrl}${path}${queryString}` : `${path}${queryString}`; const headers = { 'Content-Type': 'application/json', @@ -89,9 +89,16 @@ export async function api({ }); let body; - try { - body = responseType === 'json' ? await response.json() : response.body; - } catch (e) {} + if (responseType === 'json') { + const rawBody = await response.text(); + try { + body = responseType === 'json' ? JSON.parse(rawBody) : response.body; + } catch (e) { + body = rawBody; + } + } else { + body = response.body; + } if (API_DEBUG) { console.log( diff --git a/src/command.ts b/src/command.ts index 2d242d7..894b820 100644 --- a/src/command.ts +++ b/src/command.ts @@ -46,7 +46,12 @@ export abstract class CliCommand extends Command { return this.error('The API is currently unavailable. Please try again later'); default: return this.error( - 'Unknown server error. Please check that your are using the latest version of the Squid CLI. If the error persists please open an issue at https://github.com/subsquid/subsquid-cli and report to t.me/HydraDevs', + [ + `Unknown network error occurred`, + `==================`, + `Status: ${status}`, + `Body:\n${JSON.stringify(body)}`, + ].join('\n'), ); } } From 9a7acdf63175431d534b60585a6ba1deb518e9cb Mon Sep 17 00:00:00 2001 From: Igor Mahov Date: Mon, 11 Dec 2023 13:56:49 +0300 Subject: [PATCH 2/3] feat: add source files build fail status --- src/api/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/types.ts b/src/api/types.ts index 0c69184..64cc41c 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -18,7 +18,7 @@ export type DeployResponse = { squidName?: string; versionName?: string; deploymentUrl?: string; - failed: 'NO' | 'UNEXPECTED' | 'PERMISSIONS' | 'REQUIREMENTS'; + failed: 'NO' | 'UNEXPECTED' | 'PERMISSIONS' | 'REQUIREMENTS' | 'SOURCE_FILES_BUILD_FAILED'; logs: { severity: 'debug' | 'warn' | 'info' | 'error'; message: string }[]; createdAt: string; }; From b18d0ecb8ad0ca0ae78b956004ba72b4fa5aa6c8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 02:35:22 +0000 Subject: [PATCH 3/3] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..5db72dd --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] +}