vertx-web icon indicating copy to clipboard operation
vertx-web copied to clipboard

Hook consumer for error reply in SockJS handler

Open zero88 opened this issue 6 years ago • 4 comments

Version

  • vert.x core: 3.6.0
  • vert.x web: 3.6.0

Context

When encountered error in a websocket call via sockjs, I would like unify reply message of vertx with my system. For example: {"type":"err","body":"invalid_json"} => {"status":"FAILED","error":{"code":"INVALID_ARGUMENT","message":"Message format is not correct"}}

I think vertx can change a little bit SockJSHandlerImpl:

  • Change it from private static to protected https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/handler/sockjs/impl/EventBusBridgeImpl.java#L551-L554
  • Provide one more replyError protected method to handle json message https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/handler/sockjs/impl/EventBusBridgeImpl.java#L457-L463

Btw, should we use BridgeEventType instead of plain String in here (reason: case sensitive) https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/handler/sockjs/impl/EventBusBridgeImpl.java#L136-L150

zero88 avatar Dec 25 '18 02:12 zero88

Sounds interesting. Are you willing to contribute?

slinkydeveloper avatar May 03 '19 09:05 slinkydeveloper

More than making replyError protected, it should add to error object the error string as "message" key, more than "body" key

slinkydeveloper avatar May 03 '19 09:05 slinkydeveloper

sorry, I'm using IE :stuck_out_tongue_closed_eyes: 2 years then almost forget this ticket

zero88 avatar Jul 16 '21 04:07 zero88

This issue is still here. It might related to https://github.com/vert-x3/vertx-web/issues/2001

zero88 avatar Jul 16 '21 04:07 zero88