UNPKG

@scaleway/sdk-client

Version:
32 lines (31 loc) 868 B
import { ScalewayError } from "../scw-error.js"; class ResourceExpiredError extends ScalewayError { constructor(status, body, resource, resourceId, expiredSince) { super( status, body, `resource ${resource} with ID ${resourceId} expired since ${expiredSince.toISOString()}` ); this.status = status; this.body = body; this.resource = resource; this.resourceId = resourceId; this.expiredSince = expiredSince; this.name = "ResourceExpiredError"; } static fromJSON(status, obj) { if (typeof obj.resource !== "string" || typeof obj.resource_id !== "string" || typeof obj.expired_since !== "string") { return null; } return new ResourceExpiredError( status, obj, obj.resource, obj.resource_id, new Date(obj.expired_since) ); } } export { ResourceExpiredError };