org.glassfish.jersey.spi
Class Errors

java.lang.Object
  extended by org.glassfish.jersey.spi.Errors

public class Errors
extends Object

Errors utility used to file processing errors (e.g. validation, provider, resource building errors).

Error filing methods (#warning, #error, #fatal) can be invoked only in the "error scope" which is created by process(org.glassfish.jersey.spi.Errors.Closure) or processWithException(org.glassfish.jersey.spi.Errors.Closure) methods. Filed error messages are present also in this scope.

TODO do not use static thread local?

Author:
Michal Gajdos (michal.gajdos at oracle.com)

Nested Class Summary
static interface Errors.Closure<T>
          Closure interface.
static class Errors.ErrorMessage
          Generic error message.
static class Errors.ErrorMessagesException
          Error message exception.
 
Method Summary
static void error(Object source, String message, boolean isFatal)
          Add an error message to the list of errors.
static void error(String message, boolean isFatal)
          Add an error message to the list of errors.
static void fatal(Object source, String message)
          Add a fatal error message to the list of errors.
static boolean fatalIssuesFound()
          Indicates whether a fatal error message is present in the list of all errors.
static List<Errors.ErrorMessage> getErrorMessages()
          Return all error messages.
static List<Errors.ErrorMessage> getErrorMessages(boolean afterMark)
          Return list of error messages filed after the mark flag was set.
static void mark()
           
static
<T> T
process(Errors.Closure<T> closure)
          Invoke given closure and gather errors.
static
<T> T
processWithException(Errors.Closure<T> closure)
          Invoke given closure and gather errors.
static void reset()
           
static void unmark()
           
static void warning(Object source, String message)
          Add a warning message to the list of errors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

error

public static void error(String message,
                         boolean isFatal)
Add an error message to the list of errors.

Parameters:
message - message of the error.
isFatal - indicates whether this error should be treated as fatal error.

error

public static void error(Object source,
                         String message,
                         boolean isFatal)
Add an error message to the list of errors.

Parameters:
source - source of the error.
message - message of the error.
isFatal - indicates whether this error should be treated as fatal error.

fatal

public static void fatal(Object source,
                         String message)
Add a fatal error message to the list of errors.

Parameters:
source - source of the error.
message - message of the error.

warning

public static void warning(Object source,
                           String message)
Add a warning message to the list of errors.

Parameters:
source - source of the error.
message - message of the error.

fatalIssuesFound

public static boolean fatalIssuesFound()
Indicates whether a fatal error message is present in the list of all errors.


process

public static <T> T process(Errors.Closure<T> closure)
Invoke given closure and gather errors. After the closure method returns all gathered errors are logged and even if there is a fatal error present in the list of errors no exception is thrown.

Parameters:
closure - closure to be invoked.

processWithException

public static <T> T processWithException(Errors.Closure<T> closure)
Invoke given closure and gather errors. After the closure method returns all gathered errors are logged and if there is a fatal error present in the list of errors an exception is thrown.

Parameters:
closure - closure to be invoked.

getErrorMessages

public static List<Errors.ErrorMessage> getErrorMessages()
Return all error messages.

Returns:
non-null error list.

getErrorMessages

public static List<Errors.ErrorMessage> getErrorMessages(boolean afterMark)
Return list of error messages filed after the mark flag was set.

Returns:
non-null error list.

mark

public static void mark()

unmark

public static void unmark()

reset

public static void reset()


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.