Product Engineer, CTO & a Beer Enthusiast
Experiments, thoughts and scripts documented for posterity.
implicit def myExceptionHandler(implicit log: LoggingContext) = ExceptionHandler.apply { case m: MappingException => { respondWithMediaType(`application/json`) { val errorMsg = ReponseError("MalformedBody", m.getMessage) ctx => ctx.complete(415, errorMsg) } } case e: SomeCustomException => ctx => { val errorMsg = ReponseError("BadRequest", e.getMessage) ctx.complete(400, errorMsg) } case e: Exception => ctx => { val errorMsg = ReponseError("InternalServerError", e.getMessage) ctx.complete(500, errorMsg) } }Checkout out these error/httpStatus code from various RestAPIs: