koa2-router
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -104,3 +104,3 @@ /*! | ||
if ('string' !== typeof name) { | ||
throw new Error('invalid param() call, got name type ' + typeof name); | ||
throw new TypeError('invalid param() call, got name type ' + gettype(name)); | ||
} | ||
@@ -115,3 +115,3 @@ | ||
if ('function' !== typeof fn) { | ||
throw new Error('invalid param() call for ' + name + ', got ' + fn); | ||
throw new TypeError('invalid param() call for ' + name + ', got ' + gettype(fn)); | ||
} | ||
@@ -387,3 +387,3 @@ | ||
// single param callbacks | ||
function paramCallback() { | ||
async function paramCallback() { | ||
var fn = paramCallbacks[paramIndex++]; | ||
@@ -396,6 +396,8 @@ | ||
return fn(ctx, paramCallback, paramVal, key.name).catch(function(e) { | ||
try { | ||
await fn(ctx, paramCallback, paramVal, key.name); | ||
} finally { | ||
// store updated value | ||
paramCalled.value = ctx.params[key.name]; | ||
}); | ||
} | ||
} | ||
@@ -402,0 +404,0 @@ }; |
@@ -61,3 +61,7 @@ /*! | ||
// promisify the handle result | ||
return Promise.resolve(fn(ctx, next)); | ||
try { | ||
return Promise.resolve(fn(ctx, next)); | ||
} catch(e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
@@ -64,0 +68,0 @@ |
@@ -195,3 +195,3 @@ /*! | ||
var msg = 'Route.' + method + '() requires a callback function but got a ' + type | ||
throw new Error(msg); | ||
throw new TypeError(msg); | ||
} | ||
@@ -198,0 +198,0 @@ |
{ | ||
"name": "koa2-router", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A express-liked router component for koa2", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
24971
826