Added PathError for easy detection
This commit is contained in:
parent
3a389de72e
commit
b1005227ab
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.20.7",
|
||||
"version": "0.20.8",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -52,6 +52,8 @@ export function PES(str: TemplateStringsArray, ...args: any[]) {
|
||||
return PathEvent.toString(paths, <any>methods?.split(''));
|
||||
}
|
||||
|
||||
export class PathError extends Error { }
|
||||
|
||||
/**
|
||||
* A event broken down into its core components for easy processing
|
||||
* Event Structure: `module/path/name:property:method`
|
||||
@ -172,7 +174,7 @@ export class PathEvent {
|
||||
* @param has Target must have at least one of these path
|
||||
*/
|
||||
static hasFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void {
|
||||
if(!PathEvent.has(target, ...has)) throw new Error(`Requires one of: ${makeArray(has).join(', ')}`);
|
||||
if(!PathEvent.has(target, ...has)) throw new PathError(`Requires one of: ${makeArray(has).join(', ')}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,7 +184,7 @@ export class PathEvent {
|
||||
* @param has Target must have all these paths
|
||||
*/
|
||||
static hasAllFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void {
|
||||
if(!PathEvent.hasAll(target, ...has)) throw new Error(`Requires all: ${makeArray(has).join(', ')}`);
|
||||
if(!PathEvent.hasAll(target, ...has)) throw new PathError(`Requires all: ${makeArray(has).join(', ')}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user