vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

Unable to attach an exception handler to client connection

Open javajosh opened this issue 13 years ago • 4 comments

//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() }

javajosh avatar Apr 11 '13 14:04 javajosh

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)

winash avatar Apr 11 '13 17:04 winash

Have you tried this code @winash? Because I did and it has the same problem.

javajosh avatar Apr 12 '13 10:04 javajosh

@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
            }
        })

winash avatar Apr 12 '13 11:04 winash

I think this is already fixed in 2.0

purplefox avatar Apr 19 '13 14:04 purplefox