Skip to content

Commit

Permalink
fix(stdlib): type input of AppError#cause as unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed Nov 21, 2024
1 parent 238245b commit 8ed5778
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions packages/stdlib/src/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AppError extends Error {
* @param {string} key
* @param {number} status
* @param {Record<string, any>} [info={}]
* @param {Error} [cause]
* @param {unknown} [cause]
*/
constructor(key, status, info, cause) {
let errMessage = info?.message ?? info?.type ?? "";
Expand All @@ -32,6 +32,9 @@ export class AppError extends Error {
this.key = key;
this.status = status;
this.info = info || {};

/** @type {Error} */
// @ts-expect-error force cast
this.cause = cause;

Object.setPrototypeOf(this, AppError.prototype);
Expand Down Expand Up @@ -64,7 +67,7 @@ export class AppError extends Error {

/**
* @param {Record<string, any>} [info={}]
* @param {Error} [error]
* @param {unknown} [error]
* @returns {AppError}
*/
static notFound(info = {}, error = undefined) {
Expand All @@ -73,7 +76,7 @@ export class AppError extends Error {

/**
* @param {Record<string, any>} [info={}]
* @param {Error} [error]
* @param {unknown} [error]
* @returns {AppError}
*/
static notImplemented(info = {}, error = undefined) {
Expand All @@ -82,7 +85,7 @@ export class AppError extends Error {

/**
* @param {Record<string, any>} [info={}]
* @param {Error} [error]
* @param {unknown} [error]
* @returns {AppError}
*/
static serverError(info = {}, error = undefined) {
Expand All @@ -92,7 +95,7 @@ export class AppError extends Error {
/**
* @param {string} key
* @param {Record<string, any>} [info={}]
* @param {Error} [error]
* @param {unknown} [error]
* @returns {AppError}
*/
static validationError(key, info = {}, error = undefined) {
Expand Down
2 changes: 1 addition & 1 deletion packages/store/src/object-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function objectStorageEnsureBucket(s3Client, options) {
throw AppError.serverError(
{
message: "Could not create S3 bucket",
}, // @ts-expect-error
},
e,
);
}
Expand Down

0 comments on commit 8ed5778

Please sign in to comment.