org.apache.pig
Class PigException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by org.apache.pig.PigException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BackendException, FrontendException

public class PigException
extends IOException

All exceptions in Pig are encapsulated in the PigException class. Details such as the source of the error, error message, error code, etc. are contained in this class. The default values for the attributes are: errorSource = BUG errorCode = 0 retriable = false detailedMessage = null

See Also:
Serialized Form

Field Summary
static byte BUG
           
protected  String detailedMessage
           
static byte ERROR
           
protected  int errorCode
           
protected  byte errorSource
           
static byte INPUT
           
protected  boolean markedAsShowToUser
           
static byte REMOTE_ENVIRONMENT
           
protected  boolean retriable
           
static byte USER_ENVIRONMENT
           
 
Constructor Summary
PigException()
          Create a new PigException with null as the error message.
PigException(String message)
          Create a new PigException with the specified message.
PigException(String message, int errCode)
          Create a new PigException with the specified message and cause.
PigException(String message, int errCode, boolean retry)
          Create a new PigException with the specified message and cause.
PigException(String message, int errCode, byte errSrc)
          Create a new PigException with the specified message and cause.
PigException(String message, int errCode, byte errSrc, boolean retry)
          Create a new PigException with the specified message and cause.
PigException(String message, int errCode, byte errSrc, boolean retry, String detailedMsg)
          Create a new PigException with the specified message and cause.
PigException(String message, int errCode, byte errSrc, boolean retry, String detailedMsg, Throwable cause)
          Create a new PigException with the specified message, error code, error source, retriable or not, detalied message for the developer and cause.
PigException(String message, int errCode, byte errSrc, Throwable cause)
          Create a new PigException with the specified message and cause.
PigException(String message, int errCode, Throwable cause)
          Create a new PigException with the specified message and cause.
PigException(String message, Throwable cause)
          Create a new PigException with the specified message and cause.
PigException(Throwable cause)
          Create a new PigException with the specified cause.
 
Method Summary
static byte determineErrorSource(int errCode)
          A static method to determine the error source given the error code
 String getDetailedMessage()
          Returns the detailed message used by developers for debugging
 int getErrorCode()
          Returns the error code of the exception
 byte getErrorSource()
          Returns the error source of the exception.
 boolean getMarkedAsShowToUser()
          Check if this PigException is marked as the ones whose message is to be displayed to the user.
static boolean isBug(byte errSource)
          A static method to query if an error source is due to a bug or not.
static boolean isInput(byte errSource)
          A static method to query if an error source is due to an input or not.
static boolean isRemoteEnvironment(byte errSource)
          A static method to query if an error source is due to the remote environment or not.
static boolean isUserEnvironment(byte errSource)
          A static method to query if an error source is due to the user environment or not.
 boolean retriable()
          Checks if the exception is retriable.
 void setDetailedMessage(String detailMsg)
          Set the detailed message of the exception
 void setErrorCode(int code)
          Set the error code of the exception
 void setErrorSource(byte src)
          Set the error source of the exception
 void setMarkedAsShowToUser(boolean showToUser)
          Mark this exception as a good candidate for showing its message to the pig user
 void setRetriable(boolean retry)
          Set the retriable attribute of the exception
 String toString()
          Returns a short description of this throwable.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INPUT

public static final byte INPUT
See Also:
Constant Field Values

BUG

public static final byte BUG
See Also:
Constant Field Values

USER_ENVIRONMENT

public static final byte USER_ENVIRONMENT
See Also:
Constant Field Values

REMOTE_ENVIRONMENT

public static final byte REMOTE_ENVIRONMENT
See Also:
Constant Field Values

ERROR

public static final byte ERROR
See Also:
Constant Field Values

errorCode

protected int errorCode

errorSource

protected byte errorSource

retriable

protected boolean retriable

detailedMessage

protected String detailedMessage

markedAsShowToUser

protected boolean markedAsShowToUser
Constructor Detail

PigException

public PigException()
Create a new PigException with null as the error message.


PigException

public PigException(String message)
Create a new PigException with the specified message.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user

PigException

public PigException(Throwable cause)
Create a new PigException with the specified cause.

Parameters:
cause - - The cause (which is saved for later retrieval by the Throwable.getCause() method) indicating the source of this exception. A null value is permitted, and indicates that the cause is nonexistent or unknown.

PigException

public PigException(String message,
                    Throwable cause)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
cause - - The cause (which is saved for later retrieval by the Throwable.getCause() method) indicating the source of this exception. A null value is permitted, and indicates that the cause is nonexistent or unknown.

PigException

public PigException(String message,
                    int errCode)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user

PigException

public PigException(String message,
                    int errCode,
                    Throwable cause)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user
cause - - The cause (which is saved for later retrieval by the Throwable.getCause() method) indicating the source of this exception. A null value is permitted, and indicates that the cause is nonexistent or unknown.

PigException

public PigException(String message,
                    int errCode,
                    byte errSrc)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user
errSrc - - The error source

PigException

public PigException(String message,
                    int errCode,
                    byte errSrc,
                    Throwable cause)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user
errSrc - - The error source
cause - - The cause (which is saved for later retrieval by the Throwable.getCause() method) indicating the source of this exception. A null value is permitted, and indicates that the cause is nonexistent or unknown.

PigException

public PigException(String message,
                    int errCode,
                    boolean retry)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user
retry - - If the exception is retriable or not

PigException

public PigException(String message,
                    int errCode,
                    byte errSrc,
                    boolean retry)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user
errSrc - - The error source
retry - - If the exception is retriable or not

PigException

public PigException(String message,
                    int errCode,
                    byte errSrc,
                    boolean retry,
                    String detailedMsg)
Create a new PigException with the specified message and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user
errSrc - - The error source
retry - - If the exception is retriable or not
detailedMsg - - The detailed message shown to the developer

PigException

public PigException(String message,
                    int errCode,
                    byte errSrc,
                    boolean retry,
                    String detailedMsg,
                    Throwable cause)
Create a new PigException with the specified message, error code, error source, retriable or not, detalied message for the developer and cause.

Parameters:
message - - The error message (which is saved for later retrieval by the Throwable.getMessage() method) shown to the user
errCode - - The error code shown to the user
errSrc - - The error source
retry - - If the exception is retriable or not
detailedMsg - - The detailed message shown to the developer
cause - - The cause (which is saved for later retrieval by the Throwable.getCause() method) indicating the source of this exception. A null value is permitted, and indicates that the cause is nonexistent or unknown.
Method Detail

isInput

public static boolean isInput(byte errSource)
A static method to query if an error source is due to an input or not.

Parameters:
errSource - - byte that indicates the error source
Returns:
true if the error source is an input; false otherwise

isBug

public static boolean isBug(byte errSource)
A static method to query if an error source is due to a bug or not.

Parameters:
errSource - - byte that indicates the error source
Returns:
true if the error source is a bug; false otherwise

isUserEnvironment

public static boolean isUserEnvironment(byte errSource)
A static method to query if an error source is due to the user environment or not.

Parameters:
errSource - - byte that indicates the error source
Returns:
true if the error source is due to the user environment; false otherwise

isRemoteEnvironment

public static boolean isRemoteEnvironment(byte errSource)
A static method to query if an error source is due to the remote environment or not.

Parameters:
errSource - - byte that indicates the error source
Returns:
true if the error source is due to the remote environment; false otherwise

determineErrorSource

public static byte determineErrorSource(int errCode)
A static method to determine the error source given the error code

Parameters:
errCode - - integer error code
Returns:
byte that indicates the error source

retriable

public boolean retriable()
Checks if the exception is retriable.

Returns:
if the exception is retriable or not

setRetriable

public void setRetriable(boolean retry)
Set the retriable attribute of the exception

Parameters:
retry - - true if retriable; false otherwise

getErrorSource

public byte getErrorSource()
Returns the error source of the exception. Can be more than one source.

Returns:
error sources represented as a byte

setErrorSource

public void setErrorSource(byte src)
Set the error source of the exception

Parameters:
src - - byte representing the error sources

getErrorCode

public int getErrorCode()
Returns the error code of the exception

Returns:
error code of the exception

setErrorCode

public void setErrorCode(int code)
Set the error code of the exception

Parameters:
code - - error code

getDetailedMessage

public String getDetailedMessage()
Returns the detailed message used by developers for debugging

Returns:
detailed message

setDetailedMessage

public void setDetailedMessage(String detailMsg)
Set the detailed message of the exception

Parameters:
detailMsg - - detailed message to be used by developers

getMarkedAsShowToUser

public boolean getMarkedAsShowToUser()
Check if this PigException is marked as the ones whose message is to be displayed to the user. This can be used to indicate if the corresponding error message is a good candidate for displaying to the end user, instead of drilling down the stack trace further.

Returns:
true if this pig exception is marked as appropriate to be displayed to the user

setMarkedAsShowToUser

public void setMarkedAsShowToUser(boolean showToUser)
Mark this exception as a good candidate for showing its message to the pig user


toString

public String toString()
Returns a short description of this throwable. The result is the concatenation of: If getLocalizedMessage returns null, then just the class name is returned.

Overrides:
toString in class Throwable
Returns:
a string representation of this throwable.


Copyright © 2007-2012 The Apache Software Foundation