Skip to content

Commit ece83fa

Browse files
authored
feat: update QuotasExceededError message with clearer instructions (#1845)
1 parent 750a7c0 commit ece83fa

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

packages/clients/src/scw/errors/non-standard/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('InvalidRequestError', () => {
5050
},
5151
])
5252
expect(error.message).toBe(
53-
'quota(s) exceeded: compute_snapshots_type_b_ssd_available has reached its quota (0/0)',
53+
'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.',
5454
)
5555
})
5656

packages/clients/src/scw/errors/standard/__tests__/index.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line import/no-extraneous-dependencies
21
import { describe, expect, it } from 'vitest'
32
import type { JSONObject } from '../../../../helpers/json'
43
import { parseScalewayError } from '../../error-parser'
@@ -93,11 +92,9 @@ describe('QuotasExceededError', () => {
9392
type: 'quotas_exceeded',
9493
}
9594

96-
it(`parses a valid input`, () => {
97-
expect(parseScalewayError(403, body).toString()).toBe(
98-
`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)`,
99-
)
100-
})
95+
expect(parseScalewayError(403, body).toString()).toContain(
96+
"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.",
97+
)
10198

10299
it(`doesn't parse invalid details object`, () => {
103100
expect(

packages/clients/src/scw/errors/standard/quotas-exceeded-error.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ScalewayError } from '../scw-error'
77
*
88
* @public
99
*/
10-
export type QuotasExceededErrorScope = {
10+
export interface QuotasExceededErrorScope {
1111
kind: 'organization' | 'project'
1212
id: string
1313
}
@@ -17,7 +17,7 @@ export type QuotasExceededErrorScope = {
1717
*
1818
* @public
1919
*/
20-
export type QuotasExceededErrorDetails = {
20+
export interface QuotasExceededErrorDetails {
2121
readonly resource: string
2222
readonly quota: number
2323
readonly current: number
@@ -35,7 +35,7 @@ export type QuotasExceededErrorDetails = {
3535
const buildMessage = (list: QuotasExceededErrorDetails[]): string =>
3636
`quota(s) exceeded: ${list
3737
.map(details => {
38-
const message = `${details.resource} has reached its quota (${details.current}/${details.quota})`
38+
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.`
3939
4040
return details.scope
4141
? `${message} for ${details.scope.kind} '${details.scope.id}'`

0 commit comments

Comments
 (0)