Browse Source

[Router] use a new UnexpectedArgumentsError

Jakob Ackermann 6 years ago
parent
commit
880056d397
2 changed files with 9 additions and 1 deletions
  1. 7 0
      services/real-time/app/js/Errors.js
  2. 2 1
      services/real-time/app/js/Router.js

+ 7 - 0
services/real-time/app/js/Errors.js

@@ -68,6 +68,12 @@ class NullBytesInOpError extends OError {
   }
   }
 }
 }
 
 
+class UnexpectedArgumentsError extends OError {
+  constructor() {
+    super('unexpected arguments')
+  }
+}
+
 class UpdateTooLargeError extends OError {
 class UpdateTooLargeError extends OError {
   constructor(updateSize) {
   constructor(updateSize) {
     super('update is too large', { updateSize })
     super('update is too large', { updateSize })
@@ -91,6 +97,7 @@ module.exports = {
   NotAuthorizedError,
   NotAuthorizedError,
   NotJoinedError,
   NotJoinedError,
   NullBytesInOpError,
   NullBytesInOpError,
+  UnexpectedArgumentsError,
   UpdateTooLargeError,
   UpdateTooLargeError,
   WebApiRequestFailedError
   WebApiRequestFailedError
 }
 }

+ 2 - 1
services/real-time/app/js/Router.js

@@ -9,6 +9,7 @@ const HttpController = require('./HttpController')
 const HttpApiController = require('./HttpApiController')
 const HttpApiController = require('./HttpApiController')
 const bodyParser = require('body-parser')
 const bodyParser = require('body-parser')
 const base64id = require('base64id')
 const base64id = require('base64id')
+const { UnexpectedArgumentsError } = require('./Errors')
 
 
 const basicAuth = require('basic-auth-connect')
 const basicAuth = require('basic-auth-connect')
 const httpAuth = basicAuth(function (user, pass) {
 const httpAuth = basicAuth(function (user, pass) {
@@ -64,7 +65,7 @@ module.exports = Router = {
   },
   },
 
 
   _handleInvalidArguments(client, method, args) {
   _handleInvalidArguments(client, method, args) {
-    const error = new Error('unexpected arguments')
+    const error = new UnexpectedArgumentsError()
     let callback = args[args.length - 1]
     let callback = args[args.length - 1]
     if (typeof callback !== 'function') {
     if (typeof callback !== 'function') {
       callback = function () {}
       callback = function () {}