Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
)
})

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ScalewayError } from '../scw-error'
*
* @public
*/
export type QuotasExceededErrorScope = {
export interface QuotasExceededErrorScope {
kind: 'organization' | 'project'
id: string
}
Expand All @@ -17,7 +17,7 @@ export type QuotasExceededErrorScope = {
*
* @public
*/
export type QuotasExceededErrorDetails = {
export interface QuotasExceededErrorDetails {
readonly resource: string
readonly quota: number
readonly current: number
Expand All @@ -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}'`
Expand Down
Loading