Documentation



Send Feedback | Print | PDF | ePub | Mobi
Java Platform, Enterprise Edition: The Java EE Tutorial

18.9 Handling Errors

To designate a method that handles errors in an annotated WebSocket endpoint, decorate it with @OnError:

@ServerEndpoint("/testendpoint")
public class TestEndpoint {
 ...
 @OnError
 public void error(Session session, Throwable t) {
 t.printStackTrace();
 ...
 }
}

This method is invoked when there are connection problems, runtime errors from message handlers, or conversion errors when decoding messages.

Table of Contents

Java Platform, Enterprise Edition: The Java EE Tutorial

|

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Legal Notices

AltStyle によって変換されたページ (->オリジナル) /