@directus/errors
Advanced tools
Comparing version 0.4.0 to 1.0.0
@@ -178,3 +178,6 @@ import { Range } from '@directus/storage'; | ||
declare const ForbiddenError: DirectusErrorConstructor<void>; | ||
interface ForbiddenErrorExtensions { | ||
reason: string; | ||
} | ||
declare const ForbiddenError: DirectusErrorConstructor<void | ForbiddenErrorExtensions>; | ||
@@ -181,0 +184,0 @@ declare const InternalServerError: DirectusErrorConstructor<void>; |
@@ -75,7 +75,11 @@ // src/create-error.ts | ||
// src/errors/forbidden.ts | ||
var ForbiddenError = createError("FORBIDDEN" /* Forbidden */, `You don't have permission to access this.`, 403); | ||
var messageConstructor2 = (ext) => { | ||
if (ext?.reason) return ext.reason; | ||
return `You don't have permission to access this.`; | ||
}; | ||
var ForbiddenError = createError("FORBIDDEN" /* Forbidden */, messageConstructor2, 403); | ||
// src/errors/hit-rate-limit.ts | ||
import ms from "ms"; | ||
var messageConstructor2 = (extensions) => { | ||
var messageConstructor3 = (extensions) => { | ||
const msBeforeNext = extensions.reset.getTime() - Date.now(); | ||
@@ -86,3 +90,3 @@ return `Too many requests, retry after ${ms(msBeforeNext)}.`; | ||
"REQUESTS_EXCEEDED" /* RequestsExceeded */, | ||
messageConstructor2, | ||
messageConstructor3, | ||
429 | ||
@@ -105,3 +109,3 @@ ); | ||
// src/errors/invalid-foreign-key.ts | ||
var messageConstructor3 = ({ collection, field }) => { | ||
var messageConstructor4 = ({ collection, field }) => { | ||
let message = "Invalid foreign key"; | ||
@@ -119,3 +123,3 @@ if (field) { | ||
"INVALID_FOREIGN_KEY" /* InvalidForeignKey */, | ||
messageConstructor3, | ||
messageConstructor4, | ||
400 | ||
@@ -131,6 +135,6 @@ ); | ||
// src/errors/invalid-payload.ts | ||
var messageConstructor4 = ({ reason }) => `Invalid payload. ${reason}.`; | ||
var messageConstructor5 = ({ reason }) => `Invalid payload. ${reason}.`; | ||
var InvalidPayloadError = createError( | ||
"INVALID_PAYLOAD" /* InvalidPayload */, | ||
messageConstructor4, | ||
messageConstructor5, | ||
400 | ||
@@ -150,6 +154,6 @@ ); | ||
// src/errors/invalid-query.ts | ||
var messageConstructor5 = ({ reason }) => `Invalid query. ${reason}.`; | ||
var messageConstructor6 = ({ reason }) => `Invalid query. ${reason}.`; | ||
var InvalidQueryError = createError( | ||
"INVALID_QUERY" /* InvalidQuery */, | ||
messageConstructor5, | ||
messageConstructor6, | ||
400 | ||
@@ -162,3 +166,3 @@ ); | ||
// src/errors/limit-exceeded.ts | ||
var messageConstructor6 = ({ category }) => { | ||
var messageConstructor7 = ({ category }) => { | ||
return `${category} limit exceeded.`; | ||
@@ -168,3 +172,3 @@ }; | ||
"LIMIT_EXCEEDED" /* LimitExceeded */, | ||
messageConstructor6, | ||
messageConstructor7, | ||
403 | ||
@@ -174,6 +178,6 @@ ); | ||
// src/errors/method-not-allowed.ts | ||
var messageConstructor7 = (extensions) => `Invalid method "${extensions.current}" used. Should be one of ${extensions.allowed.map((method) => `"${method}"`).join(", ")}.`; | ||
var messageConstructor8 = (extensions) => `Invalid method "${extensions.current}" used. Should be one of ${extensions.allowed.map((method) => `"${method}"`).join(", ")}.`; | ||
var MethodNotAllowedError = createError( | ||
"METHOD_NOT_ALLOWED" /* MethodNotAllowed */, | ||
messageConstructor7, | ||
messageConstructor8, | ||
405 | ||
@@ -183,3 +187,3 @@ ); | ||
// src/errors/not-null-violation.ts | ||
var messageConstructor8 = ({ collection, field }) => { | ||
var messageConstructor9 = ({ collection, field }) => { | ||
let message = "Value "; | ||
@@ -197,3 +201,3 @@ if (field) { | ||
"NOT_NULL_VIOLATION" /* NotNullViolation */, | ||
messageConstructor8, | ||
messageConstructor9, | ||
400 | ||
@@ -210,3 +214,3 @@ ); | ||
// src/errors/range-not-satisfiable.ts | ||
var messageConstructor9 = ({ range }) => { | ||
var messageConstructor10 = ({ range }) => { | ||
const rangeString = `"${range.start ?? ""}-${range.end ?? ""}"`; | ||
@@ -217,3 +221,3 @@ return `Range ${rangeString} is invalid or the file's size doesn't match the requested range.`; | ||
"RANGE_NOT_SATISFIABLE" /* RangeNotSatisfiable */, | ||
messageConstructor9, | ||
messageConstructor10, | ||
416 | ||
@@ -223,3 +227,3 @@ ); | ||
// src/errors/record-not-unique.ts | ||
var messageConstructor10 = ({ collection, field }) => { | ||
var messageConstructor11 = ({ collection, field }) => { | ||
let message = "Value "; | ||
@@ -237,3 +241,3 @@ if (field) { | ||
"RECORD_NOT_UNIQUE" /* RecordNotUnique */, | ||
messageConstructor10, | ||
messageConstructor11, | ||
400 | ||
@@ -243,10 +247,10 @@ ); | ||
// src/errors/route-not-found.ts | ||
var messageConstructor11 = ({ path }) => `Route ${path} doesn't exist.`; | ||
var RouteNotFoundError = createError("ROUTE_NOT_FOUND" /* RouteNotFound */, messageConstructor11, 404); | ||
var messageConstructor12 = ({ path }) => `Route ${path} doesn't exist.`; | ||
var RouteNotFoundError = createError("ROUTE_NOT_FOUND" /* RouteNotFound */, messageConstructor12, 404); | ||
// src/errors/service-unavailable.ts | ||
var messageConstructor12 = ({ service, reason }) => `Service "${service}" is unavailable. ${reason}.`; | ||
var messageConstructor13 = ({ service, reason }) => `Service "${service}" is unavailable. ${reason}.`; | ||
var ServiceUnavailableError = createError( | ||
"SERVICE_UNAVAILABLE" /* ServiceUnavailable */, | ||
messageConstructor12, | ||
messageConstructor13, | ||
503 | ||
@@ -266,6 +270,6 @@ ); | ||
// src/errors/unprocessable-content.ts | ||
var messageConstructor13 = (extensions) => `Can't process content. ${extensions.reason}.`; | ||
var messageConstructor14 = (extensions) => `Can't process content. ${extensions.reason}.`; | ||
var UnprocessableContentError = createError( | ||
"UNPROCESSABLE_CONTENT" /* UnprocessableContent */, | ||
messageConstructor13, | ||
messageConstructor14, | ||
422 | ||
@@ -275,6 +279,6 @@ ); | ||
// src/errors/unsupported-media-type.ts | ||
var messageConstructor14 = (extensions) => `Unsupported media type "${extensions.mediaType}" in ${extensions.where}.`; | ||
var messageConstructor15 = (extensions) => `Unsupported media type "${extensions.mediaType}" in ${extensions.where}.`; | ||
var UnsupportedMediaTypeError = createError( | ||
"UNSUPPORTED_MEDIA_TYPE" /* UnsupportedMediaType */, | ||
messageConstructor14, | ||
messageConstructor15, | ||
415 | ||
@@ -287,3 +291,3 @@ ); | ||
// src/errors/value-out-of-range.ts | ||
var messageConstructor15 = ({ collection, field }) => { | ||
var messageConstructor16 = ({ collection, field }) => { | ||
let message = "Numeric value "; | ||
@@ -301,3 +305,3 @@ if (field) { | ||
"VALUE_OUT_OF_RANGE" /* ValueOutOfRange */, | ||
messageConstructor15, | ||
messageConstructor16, | ||
400 | ||
@@ -307,3 +311,3 @@ ); | ||
// src/errors/value-too-long.ts | ||
var messageConstructor16 = ({ collection, field }) => { | ||
var messageConstructor17 = ({ collection, field }) => { | ||
let message = "Value "; | ||
@@ -321,3 +325,3 @@ if (field) { | ||
"VALUE_TOO_LONG" /* ValueTooLong */, | ||
messageConstructor16, | ||
messageConstructor17, | ||
400 | ||
@@ -324,0 +328,0 @@ ); |
{ | ||
"name": "@directus/errors", | ||
"version": "0.4.0", | ||
"version": "1.0.0", | ||
"description": "Create consistent error objects around the codebase", | ||
@@ -25,3 +25,3 @@ "repository": { | ||
"ms": "2.1.3", | ||
"@directus/storage": "10.1.0" | ||
"@directus/storage": "11.0.0" | ||
}, | ||
@@ -34,4 +34,4 @@ "devDependencies": { | ||
"vitest": "1.5.3", | ||
"@directus/random": "0.2.8", | ||
"@directus/tsconfig": "1.0.1" | ||
"@directus/random": "1.0.0", | ||
"@directus/tsconfig": "2.0.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
23204
484
1
+ Added@directus/storage@11.0.0(transitive)
- Removed@directus/storage@10.1.0(transitive)
Updated@directus/storage@11.0.0