Package grails.util
Class GrailsUtil
- java.lang.Object
-
- grails.util.GrailsUtil
-
public final class GrailsUtil extends java.lang.ObjectGrails utility methods for command line and GUI applications.- Since:
- 0.2
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ThrowabledeepSanitize(java.lang.Throwable t)Sanitize the exception and ALL nested causesstatic voiddeprecated(java.lang.Class<?> clazz, java.lang.String methodOrPropName)Logs warning message about deprecation of specified property or method of some class.static voiddeprecated(java.lang.Class<?> clazz, java.lang.String methodOrPropName, java.lang.String version)Logs warning message about deprecation of specified property or method of some class.static voiddeprecated(java.lang.String message)Logs warning message about some deprecation and code style related hints.static java.lang.ThrowableextractRootCause(java.lang.Throwable t)Extracts the root cause of the exception, no matter how nested it isstatic java.lang.StringgetGrailsVersion()static booleanisDevelopmentEnv()Retrieves whether the current execution environment is the development one.static voidprintSanitizedStackTrace(java.lang.Throwable t)static voidprintSanitizedStackTrace(java.lang.Throwable t, java.io.PrintWriter p)static voidprintSanitizedStackTrace(java.lang.Throwable t, java.io.PrintWriter p, StackTraceFilterer stackTraceFilterer)static java.lang.ThrowablesanitizeRootCause(java.lang.Throwable t)Get the root cause of an exception and sanitize it for display to the userstatic voidwarn(java.lang.String message)Logs warning message to grails.util.GrailsUtil logger which is turned on in development mode.
-
-
-
Method Detail
-
isDevelopmentEnv
public static boolean isDevelopmentEnv()
Retrieves whether the current execution environment is the development one.- Returns:
- true if it is the development environment
-
getGrailsVersion
public static java.lang.String getGrailsVersion()
-
deprecated
public static void deprecated(java.lang.Class<?> clazz, java.lang.String methodOrPropName)Logs warning message about deprecation of specified property or method of some class.- Parameters:
clazz- A classmethodOrPropName- Name of deprecated property or method
-
deprecated
public static void deprecated(java.lang.Class<?> clazz, java.lang.String methodOrPropName, java.lang.String version)Logs warning message about deprecation of specified property or method of some class.- Parameters:
clazz- A classmethodOrPropName- Name of deprecated property or methodversion- Version of Grails release in which property or method were deprecated
-
deprecated
public static void deprecated(java.lang.String message)
Logs warning message about some deprecation and code style related hints.- Parameters:
message- Message to display
-
warn
public static void warn(java.lang.String message)
Logs warning message to grails.util.GrailsUtil logger which is turned on in development mode.- Parameters:
message- Message to display
-
printSanitizedStackTrace
public static void printSanitizedStackTrace(java.lang.Throwable t, java.io.PrintWriter p)
-
printSanitizedStackTrace
public static void printSanitizedStackTrace(java.lang.Throwable t, java.io.PrintWriter p, StackTraceFilterer stackTraceFilterer)
-
printSanitizedStackTrace
public static void printSanitizedStackTrace(java.lang.Throwable t)
-
extractRootCause
public static java.lang.Throwable extractRootCause(java.lang.Throwable t)
Extracts the root cause of the exception, no matter how nested it is
- Parameters:
t-- Returns:
- The deepest cause of the exception that can be found
-
sanitizeRootCause
public static java.lang.Throwable sanitizeRootCause(java.lang.Throwable t)
Get the root cause of an exception and sanitize it for display to the user
This will MODIFY the stacktrace of the root cause exception object and return it
- Parameters:
t-- Returns:
- The root cause exception instance, with its stace trace modified to filter out grails runtime classes
-
deepSanitize
public static java.lang.Throwable deepSanitize(java.lang.Throwable t)
Sanitize the exception and ALL nested causes
This will MODIFY the stacktrace of the exception instance and all its causes irreversibly
- Parameters:
t-- Returns:
- The root cause exception instances, with stack trace modified to filter out grails runtime classes
-
-