{"action":"closed","issue":{"url":"https://api.github.com/repos/tedeh/jayson/issues/44","labels_url":"https://api.github.com/repos/tedeh/jayson/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/tedeh/jayson/issues/44/comments","events_url":"https://api.github.com/repos/tedeh/jayson/issues/44/events","html_url":"https://github.com/tedeh/jayson/issues/44","id":67458780,"number":44,"title":"Handling wrong number of arguments","user":{"login":"bdunlay","id":420197,"avatar_url":"https://avatars.githubusercontent.com/u/420197?v=3","gravatar_id":"","url":"https://api.github.com/users/bdunlay","html_url":"https://github.com/bdunlay","followers_url":"https://api.github.com/users/bdunlay/followers","following_url":"https://api.github.com/users/bdunlay/following{/other_user}","gists_url":"https://api.github.com/users/bdunlay/gists{/gist_id}","starred_url":"https://api.github.com/users/bdunlay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdunlay/subscriptions","organizations_url":"https://api.github.com/users/bdunlay/orgs","repos_url":"https://api.github.com/users/bdunlay/repos","events_url":"https://api.github.com/users/bdunlay/events{/privacy}","received_events_url":"https://api.github.com/users/bdunlay/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-09T21:52:09Z","updated_at":"2015-04-12T15:11:22Z","closed_at":"2015-04-12T15:11:22Z","body":"The server chokes when it doesn't get the right number of arguments. For example, say you have a very simple server that defines an `add` method:\r\n\r\n```\r\nvar jayson = require(\"jayson\");\r\n\r\nvar server = jayson.server({\r\n  add: function(a, b, callback) {\r\n    callback(null, a + b);\r\n  },\r\n});\r\n\r\nserver.http().listen(3000);\r\n```\r\n\r\nUsing the CLI we can send it a request with the wrong number of parameters:\r\n\r\n```\r\njayson -u http://localhost:3000 -m add -p [1]\r\n```\r\n\r\nTh result is that the server throws an unhandled exception, and then eventually the client dies because of a closed TCP connection. \r\n\r\n```\r\n$ jayson -u http://localhost:3000 -m add -p [1]\r\n-> add(1)\r\n<- Error: socket hang up\r\n    at createHangUpError (http.js:1472:15)\r\n    at Socket.socketOnEnd [as onend] (http.js:1568:23)\r\n    at Socket.g (events.js:180:16)\r\n    at Socket.EventEmitter.emit (events.js:117:20)\r\n    at _stream_readable.js:920:16\r\n    at process._tickCallback (node.js:415:13)\r\n```\r\n\r\n```\r\n$ node simpleserver.js \r\n.../simpleserver.js:6\r\n    callback(null, a + b);\r\n    ^\r\nTypeError: undefined is not a function\r\n    at jayson.server.add (.../simpleserver.js:6:5)\r\n    at Method.execute (.../node_modules/jayson/lib/method.js:124:20)\r\n    at .../node_modules/jayson/lib/server.js:284:12\r\n    at maybeParse (.../node_modules/jayson/lib/server.js:401:5)\r\n    at Server.call (.../node_modules/jayson/lib/server.js:229:3)\r\n    at .../node_modules/jayson/lib/utils.js:180:14\r\n    at .../node_modules/jayson/node_modules/lodash/index.js:7173:25\r\n    at .../node_modules/jayson/lib/utils.js:153:7\r\n    at Object.Utils.JSON.parse (.../node_modules/jayson/lib/utils.js:273:3)\r\n    at IncomingMessage.<anonymous> (.../node_modules/jayson/lib/utils.js:151:16)\r\n```\r\n\r\nShouldn't it handle this and return an error to the client?"}}