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 11 public WebSocketException(Exception cause) { 12 this(CloseCode.InternalServerError, cause.toString(), cause); 13 } 14 15 public WebSocketException(CloseCode code, String reason) { 16 this(code, reason, null); 17 } 18 19 public WebSocketException(CloseCode code, String reason, Exception cause) { 20 super(code + ": " + reason, cause); 21 this.code = code; 22 this.reason = reason; 23 } 24 25 public CloseCode getCode() { 26 return code; 27 } 28 29 public String getReason() { 30 return reason; 31 } 32 } 33