1 23 24 package org.apache.slide.macro; 25 26 27 import java.io.StringWriter ; 28 import java.io.PrintWriter ; 29 30 import org.apache.slide.util.Messages; 31 import org.apache.slide.common.SlideException; 32 33 34 39 public class ForbiddenException extends SlideException { 40 41 42 44 45 46 51 public ForbiddenException(String objectUri) { 52 this(objectUri, new SlideException("no cause given", false)); 53 } 54 55 56 62 public ForbiddenException(String objectUri, Throwable t) { 63 super(Messages.format(ConflictException.class.getName(), objectUri, computeCause(t)), t!=null); 64 this.objectUri = objectUri; 65 this.nestedException = t; 66 } 67 68 69 70 71 73 74 77 private String objectUri; 78 79 80 81 private Throwable nestedException = null; 82 83 84 85 86 88 89 94 public String getObjectUri() { 95 return objectUri; 96 } 97 98 99 100 105 private static String computeCause(Throwable e) { 106 return computeCause(e==null?"":e.getMessage(), e); 107 } 108 109 115 private static String computeCause(String delieveredCause, Throwable e) { 116 String result = delieveredCause; 117 if (delieveredCause == null || delieveredCause.equals("")) { 118 StringWriter sw = new StringWriter (); 119 e.printStackTrace( new PrintWriter (sw, true) ); result = sw.toString(); 121 } 122 return result; 123 } 124 125 126 } 127 | Popular Tags |