1 package fi.iki.elonen; 2 3 import fi.iki.elonen.WebSocketFrame.CloseCode; 4 5 import java.io.IOException; 6 7 public class WebSocketException extends IOException { 8 private CloseCode code; 9 private String reason; 10 WebSocketException(Exception cause)11 public WebSocketException(Exception cause) { 12 this(CloseCode.InternalServerError, cause.toString(), cause); 13 } 14 WebSocketException(CloseCode code, String reason)15 public WebSocketException(CloseCode code, String reason) { 16 this(code, reason, null); 17 } 18 WebSocketException(CloseCode code, String reason, Exception cause)19 public WebSocketException(CloseCode code, String reason, Exception cause) { 20 super(code + ": " + reason, cause); 21 this.code = code; 22 this.reason = reason; 23 } 24 getCode()25 public CloseCode getCode() { 26 return code; 27 } 28 getReason()29 public String getReason() { 30 return reason; 31 } 32 } 33