diff --git a/package.json b/package.json index 3657c80..0ca46f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/jrpcgen", - "version": "1.2.5", + "version": "1.2.6", "main": "lib/index.js", "license": "MIT", "packageManager": "yarn@3.1.1", diff --git a/templates/ts_base.ts b/templates/ts_base.ts index 7c27aa2..b3b9e3f 100644 --- a/templates/ts_base.ts +++ b/templates/ts_base.ts @@ -1,14 +1,24 @@ +import { isGeneratorFunction } from "util/types"; + +function form_verficiation_error_message(type?: string, field?: string) { + let msg = "Parameter verification failed! "; + if (type && field) { + msg += `At ${type}.${field}! `; + } else if (type) { + msg += `At type ${type}! `; + } else if (field) { + msg += `At field ${field}! `; + } + return msg; +} + export class VerificationError extends Error { constructor( public readonly type?: string, public readonly field?: string, public readonly value?: any ) { - super( - "Parameter verification failed! " + - (type ? "Expected " + type + "! " : "") + - (field ? "At: " + field + "! " : "") - ); + super(form_verficiation_error_message(type, field)); } } @@ -33,4 +43,4 @@ export function apply_boolean(data: any) { return Boolean(data); } -export function apply_void(data: any) {} +export function apply_void(data: any) { }