Groovy Documentation

org.linkedin.glu.groovy.utils.json
[Groovy] Class GluGroovyJsonUtils

java.lang.Object
  org.linkedin.groovy.util.json.JsonUtils
      org.linkedin.glu.groovy.utils.json.GluGroovyJsonUtils

class GluGroovyJsonUtils
extends JsonUtils

Authors:
yan@pongasoft.com


Method Summary
static java.lang.String exceptionToJSON(java.lang.Object exception, boolean prettyPrintJson = false)

Extracts the exception stack trace and all causes and returns it as a json string

static T extractFullStackTrace(java.lang.Object exception, T out = [])

Extracts the exception stack trace and all causes.

static java.util.Collection extractStackTrace(java.lang.Object exception)

Returns the stack trace elements as a collection of maps: dc (class name), mn method name, fn field name and ln line number

static java.lang.Throwable rebuildException(java.lang.Object fullStackTrace)

This method is the opposite of extractFullStackTrace(Throwable) and will attempt to "deserialize" the full stack trace into the original exception including all the chain of causes.

static StackTraceElement[] rebuildStackTrace(java.lang.Object stackTrace)

Opposite of extractStackTrace

 

Method Detail

exceptionToJSON

static java.lang.String exceptionToJSON(java.lang.Object exception, boolean prettyPrintJson = false)
Extracts the exception stack trace and all causes and returns it as a json string
Parameters:
prettyPrintJson - if you want to pretty print the output... otherwise compact print
Returns:
the json string
See Also:
extractFullStackTrace


extractFullStackTrace

static T extractFullStackTrace(java.lang.Object exception, T out = [])
Extracts the exception stack trace and all causes. Each element in the returned collection is a map with name, message and stackTrace. stackTrace is a collection of map: dc (class name), mn method name, fn field name and ln line number
Returns:
out


extractStackTrace

static java.util.Collection extractStackTrace(java.lang.Object exception)
Returns the stack trace elements as a collection of maps: dc (class name), mn method name, fn field name and ln line number


rebuildException

static java.lang.Throwable rebuildException(java.lang.Object fullStackTrace)
This method is the opposite of extractFullStackTrace(Throwable) and will attempt to "deserialize" the full stack trace into the original exception including all the chain of causes. Note that if (due mostly to class loader issues), one of the exception cannot be rebuild, a substitute will be created in its place


rebuildStackTrace

static StackTraceElement[] rebuildStackTrace(java.lang.Object stackTrace)
Opposite of extractStackTrace


 

Groovy Documentation