Add better error message to parseIntParam

This commit is contained in:
Maciej Ziarkowski 2020-01-23 00:26:46 +00:00
parent 9734c089fa
commit fd78724203

View File

@ -1,9 +1,10 @@
import { strictParseInt } from '../parse';
export function parseIntParam(param: string) {
export function parseIntParam(param: string, paramName?: string) {
const result = strictParseInt(param);
if (isNaN(result)) {
throw new Error('Invalid parameter format: not an integer');
const paramNameString = paramName == undefined ? '' : paramName + ' ';
throw new Error(`Invalid parameter ${paramNameString}format: not an integer`);
}
return result;
}