1 5 6 package com.hp.hpl.jena.joseki; 7 8 14 public class HttpException extends JosekiException 15 { 16 public static final int noResponseCode = -1234 ; 17 private int responseCode = noResponseCode ; 18 private String responseMessage = null ; 19 20 public static final int NoServer = -404 ; 23 24 29 public HttpException(int responseCode, String responseMessage) 30 { 31 super(responseMessage) ; 32 this.responseCode = responseCode ; 33 this.responseMessage = responseMessage ; 34 } 35 36 37 41 public HttpException(int responseCode) 42 { 43 super() ; 44 this.responseCode = responseCode ; 45 this.responseMessage = null ; 46 } 47 48 51 public int getResponseCode() { return responseCode ; } 52 53 54 57 public String getResponseMessage() { return responseMessage ; } 58 59 63 public HttpException(Throwable cause) 64 { 65 super(cause); 66 this.responseCode = noResponseCode ; 67 this.responseMessage = null ; 68 } 69 70 public HttpException(String msg, Throwable cause) 71 { 72 super(msg, cause); 73 this.responseCode = noResponseCode ; 74 this.responseMessage = msg ; 75 } 76 77 public String toString() 78 { 79 StringBuffer sb = new StringBuffer () ; 80 sb.append("HttpException: ") ; 81 int code = getResponseCode() ; 82 if ( code != HttpException.noResponseCode ) 83 { 84 sb.append(code) ; 85 if ( getResponseMessage() != null ) 86 { 87 sb.append(" ") ; 88 sb.append(getResponseMessage()) ; 89 } 90 } 91 else 92 { 93 sb.append(getCause().toString()+": "+getMessage()) ; 94 } 95 return sb.toString() ; 96 } 97 } 98 99 100 126 | Popular Tags |