1 18 19 package sync4j.framework.server.error; 20 21 import sync4j.framework.core.StatusCode; 22 import sync4j.framework.core.Sync4jException; 23 24 28 public class ServerException extends Sync4jException { 29 30 32 public static int UNKNOWN = -1; 33 34 36 private int statusCode = UNKNOWN; 37 38 40 44 public ServerException(final String strMsg) { 45 super(strMsg); 46 } 47 48 54 public ServerException(final int statusCode, final String strMsg) { 55 this(statusCode, strMsg, null); 56 } 57 58 public ServerException(final String strMsg, final Throwable cause) { 59 this(UNKNOWN, strMsg, cause); 60 } 61 62 public ServerException(final int statusCode, final String strMsg, final Throwable cause) { 63 super(strMsg, cause); 64 65 this.statusCode = statusCode; 66 } 67 68 public ServerException(final Throwable cause) { 69 this(UNKNOWN, "", cause); 70 } 71 72 74 79 public int getStatusCode() { 80 return statusCode; 81 } 82 83 84 89 public String getSyncMLMessage() { 90 int code = getStatusCode(); 91 92 String msg = StatusCode.getStatusDescription(code); 93 94 return (msg == null) ? "" : msg; 95 } 96 97 102 public String getMessage() { 103 String message; 104 if (statusCode != UNKNOWN) { 105 message = statusCode 106 + " " 107 + getSyncMLMessage() 108 + " - " 109 + super.getMessage() 110 ; 111 } else { 112 message = super.getMessage(); 113 } 114 return message; 115 } 116 117 } 118 | Popular Tags |