This project has retired. For details please refer to its Attic page.
Apache REEF: Org.Apache.REEF.Utilities.Diagnostics.Exceptions Class Reference
Apache REEF  0.15.0
Retainable Evaluator Execution Framework
Static Public Member Functions | List of all members
Org.Apache.REEF.Utilities.Diagnostics.Exceptions Class Reference

Static Public Member Functions

static void Throw (Exception exception, string message, Logger logger)
 Call this method to throw an exception. More...
 
static void Throw (Exception exception, Logger logger)
 Call this method to throw an exception. More...
 
static void Caught (Exception exception, Level level, Logger logger)
 Call this method every time when an exception is caught. More...
 
static void Caught (Exception exception, Level level, string message, Logger logger)
 Call this method every time when an exception is caught. More...
 
static void CaughtAndThrow (Exception exception, Level level, Logger logger)
 
static void CaughtAndThrow (Exception exception, Level level, string message, Logger logger)
 
static bool MustRethrow (Exception exception)
 This method returns true if the exception passed as parameter is a critical exception that should have not been caught. More...
 
static string GetFullMessage (Exception e)
 Gets an exception message that includes the messages of the inner exceptions. More...
 
static void ThrowInvalidArgument (string argumentName, string message, Logger logger)
 Call this method to throw ArgumentException for an invalid argument. More...
 
static void ThrowArgumentOutOfRange (string argumentName, string message, Logger logger)
 Call this method to throw ArgumentOutOfRangeException exception. More...
 
static void ThrowIfArgumentNull (object argument, string name, Logger logger)
 Call this method to check if an argument is null and throw ArgumentNullException exception. More...
 
static void ThrowIfObjectDisposed (bool disposed, object o, Logger logger)
 Call this method to throw ObjectDisposedException if an object is disposed. More...
 

Member Function Documentation

static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught ( Exception  exception,
Level  level,
Logger  logger 
)
inlinestatic

Call this method every time when an exception is caught.

Calling this method will trace the exception and do other common processing. This method traces the exception type and message at error level and the full stack trace at all other levels.

try { // Some code that can throw } catch (Exception e) { Exceptions.Caught(e); // Exception handling code }

Parameters
exceptionThe exception being caught.
levelThe log level.
loggerThe logger from the caller class.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught ( Exception  exception,
Level  level,
string  message,
Logger  logger 
)
inlinestatic

Call this method every time when an exception is caught.

Calling this method will trace the exception and do other common processing. This method traces the exception type and message at error level and the full stack trace at all other levels.

try { // Some code that can throw } catch (Exception e) { Exceptions.Caught(e); // Exception handling code }

Parameters
exceptionThe exception being caught.
levelThe log level.
messageThe additional message to log.
loggerThe Logger from the caller class.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.CaughtAndThrow ( Exception  exception,
Level  level,
Logger  logger 
)
inlinestatic
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.CaughtAndThrow ( Exception  exception,
Level  level,
string  message,
Logger  logger 
)
inlinestatic
static string Org.Apache.REEF.Utilities.Diagnostics.Exceptions.GetFullMessage ( Exception  e)
inlinestatic

Gets an exception message that includes the messages of the inner exceptions.

Parameters
eThe exception.
Returns
The message
static bool Org.Apache.REEF.Utilities.Diagnostics.Exceptions.MustRethrow ( Exception  exception)
inlinestatic

This method returns true if the exception passed as parameter is a critical exception that should have not been caught.

Examples for such exceptions are StackOverflowException and OutOfMemoryException.

Catch statements which catch all exceptions must call this method immediately and rethrow without further processing if the method returns true.

try { // Some code that can throw } catch (Exception e) { if (Exceptions.MustRethrow(e)) { throw; } // Exception handling code }

Parameters
exceptionThe exception to be checked.
Returns
True if the exceptions is critical one and should not be caught and false otherwise.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw ( Exception  exception,
string  message,
Logger  logger 
)
inlinestatic

Call this method to throw an exception.

Calling this method will trace the exception and do other common processing, and then it will throw the exception. This method traces the exception type and message at error level and the full stack trace at all other levels.

Exceptions.Throw(new Exception("Some exception"));

Parameters
exceptionThe exception to be thrown.
messageThe message from the caller class.
loggerThe logger from the caller class.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw ( Exception  exception,
Logger  logger 
)
inlinestatic

Call this method to throw an exception.

Calling this method will trace the exception and do other common processing, and then it will throw the exception. This method traces the exception type and message at error level and the full stack trace at all other levels.

Exceptions.Throw(new Exception("Some exception"));

Parameters
exceptionThe exception to be thrown.
loggerThe logger of the caller class.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.ThrowArgumentOutOfRange ( string  argumentName,
string  message,
Logger  logger 
)
inlinestatic

Call this method to throw ArgumentOutOfRangeException exception.

Parameters
argumentNameThe invalid argument name.
messageA message explaining the reason for th exception.
loggerThe logger of the caller class.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.ThrowIfArgumentNull ( object  argument,
string  name,
Logger  logger 
)
inlinestatic

Call this method to check if an argument is null and throw ArgumentNullException exception.

Parameters
argumentThe argument to be checked.
nameThe name of the argument.
loggerThe logger of the caller class.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.ThrowIfObjectDisposed ( bool  disposed,
object  o,
Logger  logger 
)
inlinestatic

Call this method to throw ObjectDisposedException if an object is disposed.

All disposable objects should check their state and throw in the beginning of each public method. This helper method provides a shorter way to do this.

class SomeClass : IDisposable { bool _disposed; // ... public void SomePublicMethod() { Exceptions.ThrowIfObjectDisposed(_disposed, this); // Method's code } }

Parameters
disposedTrue if the object is disposed.
oThe object.
loggerThe logger of the caller class.
static void Org.Apache.REEF.Utilities.Diagnostics.Exceptions.ThrowInvalidArgument ( string  argumentName,
string  message,
Logger  logger 
)
inlinestatic

Call this method to throw ArgumentException for an invalid argument.

Parameters
argumentNameThe invalid argument name.
messageA message explaining the reason for th exception.
loggerThe logger of the caller class.

The documentation for this class was generated from the following file: