Skip to content

Commit

Permalink
Improved Error Handling in Method Schema (#44)
Browse files Browse the repository at this point in the history
* Improved Error Handling in Method Schema

* Ignore ESLint no-console

* Remove trailing space
  • Loading branch information
Furchin committed Dec 11, 2018
1 parent 61f34fb commit bee0018
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/handler.js
Expand Up @@ -22,8 +22,14 @@ function safeLog(ctx, message) {

function getSchemaArgsMetadata(methodSchema) {
// Get string names of arguments defined in the handler function
const functionArgs = fnArgs(methodSchema.handler);

let functionArgs;
try {
functionArgs = fnArgs(methodSchema.handler);
} catch (err) {
// eslint-disable-next-line no-console
console.error('Error processing method schema handler ', methodSchema);
throw new Error(err);
}
// Check whether arguments were also defined in the method schema
// If so, first validate that schema and function have same arity
if (methodSchema.args !== undefined) {
Expand Down

0 comments on commit bee0018

Please sign in to comment.