Added PathError for easy detection
All checks were successful
Build / Build NPM Project (push) Successful in 43s
Build / Tag Version (push) Successful in 8s
Build / Publish Documentation (push) Successful in 38s

This commit is contained in:
Zakary Timson 2024-10-16 19:52:47 -04:00
parent 3a389de72e
commit b1005227ab
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.20.7", "version": "0.20.8",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@ -52,6 +52,8 @@ export function PES(str: TemplateStringsArray, ...args: any[]) {
return PathEvent.toString(paths, <any>methods?.split('')); return PathEvent.toString(paths, <any>methods?.split(''));
} }
export class PathError extends Error { }
/** /**
* A event broken down into its core components for easy processing * A event broken down into its core components for easy processing
* Event Structure: `module/path/name:property:method` * 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 * @param has Target must have at least one of these path
*/ */
static hasFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void { 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 * @param has Target must have all these paths
*/ */
static hasAllFatal(target: string | PathEvent | (string | PathEvent)[], ...has: (string | PathEvent)[]): void { 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(', ')}`);
} }
/** /**