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.common.SlideException; 31 import org.apache.slide.util.Messages; 32 33 38 public class ConflictException extends SlideException { 39 40 41 43 44 49 public ConflictException(String objectUri) { 50 this(objectUri, new SlideException("no cause given", false)); 51 } 52 53 54 60 public ConflictException(String objectUri, Throwable t) { 61 super(Messages.format(ConflictException.class.getName(), objectUri, computeCause(t)), false); 62 this.objectUri = objectUri; 63 this.nestedException = t; 64 } 65 66 67 68 69 71 72 75 private String objectUri; 76 77 78 79 private Throwable nestedException = null; 80 81 82 83 84 86 87 92 public String getObjectUri() { 93 return objectUri; 94 } 95 96 97 98 103 private static String computeCause(Throwable e) { 104 return computeCause(e==null?"":e.getMessage(), e); 105 } 106 107 113 private static String computeCause(String delieveredCause, Throwable e) { 114 String result = delieveredCause; 115 if (delieveredCause == null || delieveredCause.equals("")) { 116 StringWriter sw = new StringWriter (); 117 e.printStackTrace( new PrintWriter (sw, true) ); result = sw.toString(); 119 } 120 return result; 121 } 122 123 124 } 125 | Popular Tags |