Groovy Documentation

org.linkedin.groovy.util.lang
[Groovy] Class GroovyLangUtils

java.lang.Object
  org.linkedin.util.lang.LangUtils
      org.linkedin.groovy.util.lang.GroovyLangUtils

class GroovyLangUtils
extends LangUtils

Authors:
yan@pongasoft.com


Field Summary
static java.lang.String MODULE

static java.lang.Object log

 
Property Summary
static java.lang.Object NOEXCEPTION_ERROR

Returned by noException(Closure) when an exception happens

 
Method Summary
static java.lang.Object noException(groovy.lang.Closure closure)

The closure will be executed and no exception will ever be thrown.

static java.lang.Object noException(java.lang.Object msg, java.lang.Object valueOnException, groovy.lang.Closure closure)

The closure will be executed and no exception will ever be thrown.

static java.lang.Object noExceptionWithMessage(java.lang.Object msg, groovy.lang.Closure closure)

The closure will be executed and no exception will ever be thrown.

static java.lang.Object noExceptionWithValueOnException(java.lang.Object valueOnException, groovy.lang.Closure closure)

The closure will be executed and no exception will ever be thrown.

 

Field Detail

MODULE

public static final java.lang.String MODULE


log

public static java.lang.Object log


 
Property Detail

NOEXCEPTION_ERROR

static final java.lang.Object NOEXCEPTION_ERROR
Returned by noException(Closure) when an exception happens


 
Method Detail

noException

static java.lang.Object noException(groovy.lang.Closure closure)
The closure will be executed and no exception will ever be thrown. The normal usage of this method is from a finally block. It is very dangerous to execute some code in a finally block that throws an exception because it will mask the original exception if there was one. This method will make all possible attemps to log the error in the log first (warning will contain the message of the exception, and debug will contain the full stack trace), and if it fails it will try System.err, and if this fails as well then there won't be any message logged.
Parameters:
closure
Returns:
whatever the closure returns or NOEXCEPTION_ERROR if exception


noException

static java.lang.Object noException(java.lang.Object msg, java.lang.Object valueOnException, groovy.lang.Closure closure)
The closure will be executed and no exception will ever be thrown. The normal usage of this method is from a finally block. It is very dangerous to execute some code in a finally block that throws an exception because it will mask the original exception if there was one. This method will make all possible attemps to log the error in the log first (warning will contain the message of the exception, and debug will contain the full stack trace), and if it fails it will try System.err, and if this fails as well then there won't be any message logged.
Parameters:
msg - to display in the warning (java.lang.Object#toString() will be used for rendering)
valueOnException - return value when exception
closure
Returns:
whatever the closure returns or valueOnException if exception


noExceptionWithMessage

static java.lang.Object noExceptionWithMessage(java.lang.Object msg, groovy.lang.Closure closure)
The closure will be executed and no exception will ever be thrown. The normal usage of this method is from a finally block. It is very dangerous to execute some code in a finally block that throws an exception because it will mask the original exception if there was one. This method will make all possible attemps to log the error in the log first (warning will contain the message of the exception, and debug will contain the full stack trace), and if it fails it will try System.err, and if this fails as well then there won't be any message logged.
Parameters:
msg - to display in the warning (java.lang.Object#toString() will be used for rendering)
closure
Returns:
whatever the closure returns or NOEXCEPTION_ERROR if exception


noExceptionWithValueOnException

static java.lang.Object noExceptionWithValueOnException(java.lang.Object valueOnException, groovy.lang.Closure closure)
The closure will be executed and no exception will ever be thrown. The normal usage of this method is from a finally block. It is very dangerous to execute some code in a finally block that throws an exception because it will mask the original exception if there was one. This method will make all possible attemps to log the error in the log first (warning will contain the message of the exception, and debug will contain the full stack trace), and if it fails it will try System.err, and if this fails as well then there won't be any message logged.
Parameters:
valueOnException - return value when exception
closure
Returns:
whatever the closure returns or valueOnException if exception


 

Groovy Documentation