< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/GraalError.java

Print this page




 164      */
 165     public GraalError(Throwable cause) {
 166         super(cause);
 167     }
 168 
 169     /**
 170      * This constructor creates a {@link GraalError} and adds all the
 171      * {@linkplain #addContext(String) context} of another {@link GraalError}.
 172      *
 173      * @param e the original {@link GraalError}
 174      */
 175     public GraalError(GraalError e) {
 176         super(e);
 177         context.addAll(e.context);
 178     }
 179 
 180     @Override
 181     public String toString() {
 182         StringBuilder str = new StringBuilder();
 183         str.append(super.toString());






 184         for (String s : context) {
 185             str.append("\n\tat ").append(s);
 186         }
 187         return str.toString();
 188     }
 189 
 190     private static String format(String msg, Object... args) {
 191         if (args != null) {
 192             // expand Iterable parameters into a list representation
 193             for (int i = 0; i < args.length; i++) {
 194                 if (args[i] instanceof Iterable<?>) {
 195                     ArrayList<Object> list = new ArrayList<>();
 196                     for (Object o : (Iterable<?>) args[i]) {
 197                         list.add(o);
 198                     }
 199                     args[i] = list.toString();
 200                 }
 201             }
 202         }
 203         return String.format(Locale.ENGLISH, msg, args);


 164      */
 165     public GraalError(Throwable cause) {
 166         super(cause);
 167     }
 168 
 169     /**
 170      * This constructor creates a {@link GraalError} and adds all the
 171      * {@linkplain #addContext(String) context} of another {@link GraalError}.
 172      *
 173      * @param e the original {@link GraalError}
 174      */
 175     public GraalError(GraalError e) {
 176         super(e);
 177         context.addAll(e.context);
 178     }
 179 
 180     @Override
 181     public String toString() {
 182         StringBuilder str = new StringBuilder();
 183         str.append(super.toString());
 184         str.append(context());
 185         return str.toString();
 186     }
 187 
 188     public String context() {
 189         StringBuilder str = new StringBuilder();
 190         for (String s : context) {
 191             str.append("\n\tat ").append(s);
 192         }
 193         return str.toString();
 194     }
 195 
 196     private static String format(String msg, Object... args) {
 197         if (args != null) {
 198             // expand Iterable parameters into a list representation
 199             for (int i = 0; i < args.length; i++) {
 200                 if (args[i] instanceof Iterable<?>) {
 201                     ArrayList<Object> list = new ArrayList<>();
 202                     for (Object o : (Iterable<?>) args[i]) {
 203                         list.add(o);
 204                     }
 205                     args[i] = list.toString();
 206                 }
 207             }
 208         }
 209         return String.format(Locale.ENGLISH, msg, args);
< prev index next >