diff --git a/packages/clients/src/scw/errors/non-standard/__tests__/index.test.ts b/packages/clients/src/scw/errors/non-standard/__tests__/index.test.ts index d817f91dc..efd3098dd 100644 --- a/packages/clients/src/scw/errors/non-standard/__tests__/index.test.ts +++ b/packages/clients/src/scw/errors/non-standard/__tests__/index.test.ts @@ -50,7 +50,7 @@ describe('InvalidRequestError', () => { }, ]) expect(error.message).toBe( - 'quota(s) exceeded: compute_snapshots_type_b_ssd_available has reached its quota (0/0)', + 'quota(s) exceeded: Quotas reached: You have reached the maximum number of compute_snapshots_type_b_ssd_available authorized by your Organization. Access the quotas page from your Organization dashboard to manage quotas.', ) }) diff --git a/packages/clients/src/scw/errors/standard/__tests__/index.test.ts b/packages/clients/src/scw/errors/standard/__tests__/index.test.ts index 0d46e702d..76d9562b8 100644 --- a/packages/clients/src/scw/errors/standard/__tests__/index.test.ts +++ b/packages/clients/src/scw/errors/standard/__tests__/index.test.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies import { describe, expect, it } from 'vitest' import type { JSONObject } from '../../../../helpers/json' import { parseScalewayError } from '../../error-parser' @@ -93,11 +92,9 @@ describe('QuotasExceededError', () => { type: 'quotas_exceeded', } - it(`parses a valid input`, () => { - expect(parseScalewayError(403, body).toString()).toBe( - `QuotasExceededError: quota(s) exceeded: instance_volume has reached its quota (10/10) for project 'b7a1cf21-1e90-464c-a9f6-375c4d1f4b64'; instance_volumes_l_ssd_total_gb has reached its quota (80/100) for organization '72dd6741-d748-42e7-ba65-acd07447d3e9'; instance_volumes_l_ssd_total_gb has reached its quota (70/100)`, - ) - }) + expect(parseScalewayError(403, body).toString()).toContain( + "quota(s) exceeded: Quotas reached: You have reached the maximum number of instance_volume authorized by your Organization. Access the quotas page from your Organization dashboard to manage quotas. for project 'b7a1cf21-1e90-464c-a9f6-375c4d1f4b64'; Quotas reached: You have reached the maximum number of instance_volumes_l_ssd_total_gb authorized by your Organization. Access the quotas page from your Organization dashboard to manage quotas. for organization '72dd6741-d748-42e7-ba65-acd07447d3e9'; Quotas reached: You have reached the maximum number of instance_volumes_l_ssd_total_gb authorized by your Organization. Access the quotas page from your Organization dashboard to manage quotas.", + ) it(`doesn't parse invalid details object`, () => { expect( diff --git a/packages/clients/src/scw/errors/standard/quotas-exceeded-error.ts b/packages/clients/src/scw/errors/standard/quotas-exceeded-error.ts index 0b727744a..209de9c7a 100644 --- a/packages/clients/src/scw/errors/standard/quotas-exceeded-error.ts +++ b/packages/clients/src/scw/errors/standard/quotas-exceeded-error.ts @@ -7,7 +7,7 @@ import { ScalewayError } from '../scw-error' * * @public */ -export type QuotasExceededErrorScope = { +export interface QuotasExceededErrorScope { kind: 'organization' | 'project' id: string } @@ -17,7 +17,7 @@ export type QuotasExceededErrorScope = { * * @public */ -export type QuotasExceededErrorDetails = { +export interface QuotasExceededErrorDetails { readonly resource: string readonly quota: number readonly current: number @@ -35,7 +35,7 @@ export type QuotasExceededErrorDetails = { const buildMessage = (list: QuotasExceededErrorDetails[]): string => `quota(s) exceeded: ${list .map(details => { - const message = `${details.resource} has reached its quota (${details.current}/${details.quota})` + const message = `Quotas reached: You have reached the maximum number of ${details.resource} authorized by your Organization. Access the quotas page from your Organization dashboard to manage quotas.` return details.scope ? `${message} for ${details.scope.kind} '${details.scope.id}'`