Throw an exception in scala akka -http app when multiple required post params are not supplied -


i need throw errors indicating multiple request post paramters missing in akka-http scala app, rather current behavior throws 1 parameter missing error though not provide 2 reqd post params.

for eg(current error): {   "status": 400,   "code": "",   "errormessages": "object missing required member 'pricedate'" }  should like: {   "status": 400,   "code": "",   "errormessages": "object missing required members 'pricingdate','salesorg','xxx' " }  case handlers this: //scala http code below. object customhandlers extends sprayjsonsupport defaultjsonprotocol {   implicit val errorformat = jsonformat3(errorresponse)    implicit def rejectionhandler = rejectionhandler.newbuilder()     .handle { case missingqueryparamrejection(param) =>       complete(badrequest, errorresponse(badrequest.intvalue,errormessages = s"request missing required query parameter '$param'"))     }     .handle {       case malformedqueryparamrejection(name, msg, _) ⇒         complete((badrequest, errorresponse(badrequest.intvalue,errormessages = "the query parameter '" + name + "' malformed:" + msg)))     }     .handle {       case malformedrequestcontentrejection(msg, _) ⇒         complete((badrequest, errorresponse(badrequest.intvalue,errormessages = msg)))     }     /*written 1 more case handle missing param       .handle {         case missingqueryparamrejection(msg) ⇒            complete((badrequest,errorresponse(badrequest.intvalue,errormessages = msg)))        } */     .handle {       case validationrejection(msg, _) =>         complete((badrequest), errorresponse(badrequest.intvalue,errormessages = msg))     }     .result()    //  implicit def exceptionhandler: exceptionhandler = exceptionhandler {   //    case ex: illegalargumentexception => extracturi {   //      uri => complete(httpresponse(badrequest, entity = ex.getmessage))   //    }   //  } } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -