private static int getTypeSize(char type) { switch (type) { case 'J': case 'D': return 8; case '[': case 'L': case 'I': case 'F': return 4; case 'C': case 'S': return 2; case 'B': case 'Z': return 1; } throw new ExceptionWithContext("Invalid type: %s", type); }
methodString = ReferenceUtil.getMethodDescriptor(method); } catch (Exception ex2) { throw ExceptionWithContext.withContext(ex, "Error while processing method"); throw ExceptionWithContext.withContext(ex, "Error while processing method %s", methodString);
throw new ExceptionWithContext(String.format("Cannot parse dependency value %s", bootClassPathEntry)); throw ExceptionWithContext.withContext(ex, "Error while reading boot class path entry \"%s\"", bootClassPathEntry); throw new ExceptionWithContext("Cannot locate boot class path file %s", bootClassPathEntry);
/** * Augments the given exception with the given context, and return the * result. The result is either the given exception if it was an * {@link ExceptionWithContext}, or a newly-constructed exception if it * was not. * * @param ex non-null; the exception to augment * @param str non-null; context to add * @return non-null; an appropriate instance */ public static ExceptionWithContext withContext(Throwable ex, String str, Object... formatArgs) { ExceptionWithContext ewc; if (ex instanceof ExceptionWithContext) { ewc = (ExceptionWithContext) ex; } else { ewc = new ExceptionWithContext(ex); } ewc.addContext(String.format(str, formatArgs)); return ewc; }
ex.printStackTrace(System.err); out.annotate(0, "annotation error: %s", ex.getMessage()); out.moveTo(end); reader.setOffset(end); out.annotate(0, "annotation error: %s", ex.getMessage());
/** * Prints the message and context. * * @param out non-null; where to print to */ public void printContext(PrintStream out) { out.println(getMessage()); out.print(context); }
/** * Constructs an instance. * * @param message human-oriented message * @param cause null-ok; exception that caused this one */ public ExceptionWithContext(Throwable cause, String message, Object... formatArgs) { super((message != null) ? formatMessage(message, formatArgs) : (cause != null) ? cause.getMessage() : null, cause); if (cause instanceof ExceptionWithContext) { String ctx = ((ExceptionWithContext) cause).context.toString(); context = new StringBuffer(ctx.length() + 200); context.append(ctx); } else { context = new StringBuffer(200); } }
break; default: throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType); throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x", startOffset);
/** * Augments the given exception with the given context, and return the * result. The result is either the given exception if it was an * {@link ExceptionWithContext}, or a newly-constructed exception if it * was not. * * @param ex non-null; the exception to augment * @param str non-null; context to add * @return non-null; an appropriate instance */ public static ExceptionWithContext withContext(Throwable ex, String str, Object... formatArgs) { ExceptionWithContext ewc; if (ex instanceof ExceptionWithContext) { ewc = (ExceptionWithContext) ex; } else { ewc = new ExceptionWithContext(ex); } ewc.addContext(String.format(str, formatArgs)); return ewc; }
ex.printStackTrace(System.err); out.annotate(0, "annotation error: %s", ex.getMessage()); out.moveTo(end); reader.setOffset(end); out.annotate(0, "annotation error: %s", ex.getMessage());
/** * Prints the message and context. * * @param out non-null; where to print to */ public void printContext(PrintWriter out) { out.println(getMessage()); out.print(context); } }
/** * Constructs an instance. * * @param message human-oriented message * @param cause null-ok; exception that caused this one */ public ExceptionWithContext(Throwable cause, String message, Object... formatArgs) { super((message != null) ? formatMessage(message, formatArgs) : (cause != null) ? cause.getMessage() : null, cause); if (cause instanceof ExceptionWithContext) { String ctx = ((ExceptionWithContext) cause).context.toString(); context = new StringBuffer(ctx.length() + 200); context.append(ctx); } else { context = new StringBuffer(200); } }
public ClassProto(@Nonnull ClassPath classPath, @Nonnull String type) { if (type.charAt(0) != 'L') { throw new ExceptionWithContext("Cannot construct ClassProto for non reference type: %s", type); } this.classPath = classPath; this.type = type; }
break; default: throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType); throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x", startOffset);
/** * Augments the given exception with the given context, and return the * result. The result is either the given exception if it was an * {@link ExceptionWithContext}, or a newly-constructed exception if it * was not. * * @param ex non-null; the exception to augment * @param str non-null; context to add * @return non-null; an appropriate instance */ public static ExceptionWithContext withContext(Throwable ex, String str, Object... formatArgs) { ExceptionWithContext ewc; if (ex instanceof ExceptionWithContext) { ewc = (ExceptionWithContext) ex; } else { ewc = new ExceptionWithContext(ex); } ewc.addContext(String.format(str, formatArgs)); return ewc; }
methodString = ReferenceUtil.getMethodDescriptor(method); } catch (Exception ex2) { throw ExceptionWithContext.withContext(ex, "Error while processing method"); throw ExceptionWithContext.withContext(ex, "Error while processing method %s", methodString);
ex.printStackTrace(System.err); out.annotate(0, "annotation error: %s", ex.getMessage()); out.moveTo(end); reader.setOffset(end); out.annotate(0, "annotation error: %s", ex.getMessage());
/** * Prints the message and context. * * @param out non-null; where to print to */ public void printContext(PrintWriter out) { out.println(getMessage()); out.print(context); } }
/** * Constructs an instance. * * @param message human-oriented message * @param cause null-ok; exception that caused this one */ public ExceptionWithContext(Throwable cause, String message, Object... formatArgs) { super((message != null) ? formatMessage(message, formatArgs) : (cause != null) ? cause.getMessage() : null, cause); if (cause instanceof ExceptionWithContext) { String ctx = ((ExceptionWithContext) cause).context.toString(); context = new StringBuffer(ctx.length() + 200); context.append(ctx); } else { context = new StringBuffer(200); } }
return 8; throw new ExceptionWithContext("Invalid field type: %s", field.getType());