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" + ] +} 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/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; }; 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'), ); } }