private void writeFormattedException(final String message,
final IThrowableProxy throwableProxy,
final Level level,
final Writer out)
throws IOException {
JsonGenerator generator = new JsonFactory().createJsonGenerator(out);
IThrowableProxy rootThrowable = throwableProxy;
while (this.passthroughExceptions.contains(rootThrowable.getClassName())
&& rootThrowable.getCause() != null) {
rootThrowable = rootThrowable.getCause();
}
generator.writeStartObject();
generator.writeStringField("project", this.project);
generator.writeStringField("environment", this.environment);
generator.writeStringField("serverName", this.serverName);
// FIXME this was 'throwable'
generator.writeStringField("backtrace", getStackTrace(rootThrowable));
generator.writeStringField("message", rootThrowable.getMessage());
generator.writeStringField("logMessage", message);
generator.writeStringField("type", rootThrowable.getClassName());
if (level != Level.ERROR) {
generator.writeStringField("errorLevel", level.toString());
}
writeContext(generator);
generator.writeEndObject();
generator.close();
}