vert.x
vert.x copied to clipboard
Unable to attach an exception handler to client connection
//invoke with vertx run vertx-bug.groovy
def client = vertx.createNetClient();
//The docs appear to be wrong: http://vertx.io/core_manual_groovy.html#catching-exceptions-on-the-net-client
//Caused by: groovy.lang.MissingMethodException: No signature of method: org.vertx.groovy.core.net.impl.DefaultNetClient.exceptionHandler() is applicable for argument types: (vertx-bug$_run_closure1) values: [vertx-bug$_run_closure1@32d16fe3]
client.exceptionHandler { ex -> println "Failed to connect $ex"; container.exit() }
The method is there, you can try explicitly setting a type like this
client.exceptionHandler({ ex -> println "Failed to connect $ex"; println "blah" } as Handler)
Have you tried this code @winash? Because I did and it has the same problem.
@javajosh I did try it and it works for me with the cast. In any case the underlying code seems right., Lets see what others have to say, meanwhile falling back to java might work
client.exceptionHandler(new Handler<Exception>(){
@Override
void handle(Exception event) {
// do sth
}
})
I think this is already fixed in 2.0