Comparing version 1.0.2 to 1.1.0
@@ -13,3 +13,2 @@ declare type ErreurInfos = { | ||
message: string; | ||
details?: any; | ||
}>; | ||
@@ -24,13 +23,15 @@ declare type ErreursMapCreate<Errors extends ErreursMapErrors> = { | ||
} : never; | ||
declare type FromTypes<Errors extends { | ||
kind: string; | ||
message: string; | ||
}> = { | ||
[K in Errors['kind']]: (...args: any[]) => Omit<Extract<Errors, { | ||
kind: K; | ||
}>, 'kind'>; | ||
}; | ||
declare class ErreursMap<Errors extends ErreursMapErrors> { | ||
static readonly Base: ErreursMap<{ | ||
UnknownError: (error: Error) => { | ||
message: string; | ||
error: Error; | ||
}; | ||
Unknown: (error: unknown) => { | ||
message: string; | ||
error: unknown; | ||
}; | ||
}>; | ||
static fromType<Errors extends { | ||
kind: string; | ||
message: string; | ||
}>(errors: FromTypes<Errors>): ErreursMap<FromTypes<Errors>>; | ||
readonly errors: Errors; | ||
@@ -57,2 +58,2 @@ /** | ||
export { Erreur, ErreurInfos, ErreursMap, ErreursMapCreate, ErreursMapErrors, Expand }; | ||
export { Erreur, ErreurInfos, ErreursMap, ErreursMapCreate, ErreursMapErrors, Expand, FromTypes }; |
@@ -51,3 +51,3 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var _ErreursMap = class { | ||
var ErreursMap = class { | ||
constructor(errors) { | ||
@@ -61,2 +61,5 @@ this.infered = null; | ||
} | ||
static fromType(errors) { | ||
return new ErreursMap(errors); | ||
} | ||
is(val) { | ||
@@ -93,7 +96,2 @@ if (val instanceof Erreur && val.kind in this.errors) { | ||
}; | ||
var ErreursMap = _ErreursMap; | ||
ErreursMap.Base = new _ErreursMap({ | ||
UnknownError: (error) => ({ message: error.message, error }), | ||
Unknown: (error) => ({ message: String(error), error }) | ||
}); | ||
function isPromise(val) { | ||
@@ -100,0 +98,0 @@ return Promise.resolve(val) === val; |
{ | ||
"name": "erreur", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Type safe custom errors", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
12473
233