@Deprecated public class FSRedirectException extends L10NMessageImpl
This class is the super-class for all Federation checked exceptions. Some Exception throwing guidelines: ------------------------------------- Checked exceptions are sub-classes of java.lang.Exception; methods throwing this type of exception are forced to define a throws clause in the method signature and client programmers need to catch and handle the exception with a try/catch block or declare the throws clause in their methods. Unchecked exceptions are sub-classes of java.lang.RuntimeException. Client programmers don't have to deal with the exception using a try/catch block and the method throwing it does not have to define it in its signature. - If your method encounters an abnormal condition which causes it to be unable to fulfill its contract, or throw a checked or unchecked exception (either FSRedirectException or RuntimeException). - If your method discovers that a client has breached its contract, for example, passing a null as a parameter where a non-null value is required, throw an unchecked exception (RuntimeException). - If your method is unable to fulfill its contract and you feel client programmers should consciously decide how to handle, throw checked exceptions (FSRedirectException). Embedded/Nested Exceptions: -------------------------- An exception of type FSRedirectException can embed any exception of type Throwable. Embedded exceptions ensure traceability of errors in a multi-tiered application. For example, in a simple 3- Tier model - presentation/client tier, middle/domain tier and database/persistence tier - the real cause of error might be lost by the time control, which is passed back from the persistence tier to the client tier. To ensure tracking info, the constructor FSRedirectException( message,Throwable) should be used while throwing the exception. Client programs can then invoke the #getRootCause() method to get the underlying cause. Exception hierarchy should be defined: ------------------------------------- An exception for each abnormal cause should be created. FSRedirectException should probably be thrown only by external API's. Even these should have embedded exceptions from lower level tiers. Every package should define its own exception hierarchies specific to its context, for example, account management exceptions should be defined in the accountmgmt package. Localizing Error Messages ------------------------- The java resource bundle mechanism is used to implement localization. The ResourceSet and ResourceSetManager classes are used to implement localization. Steps for creating FSRedirectException Sub-classes and messages ------------------------------------------------------ 1. Identify the package this exception will belong to. account management related exception should be part of the accountmgmt package. 2. Each package should have its own properties file to store error messages. For example accountmgmt.properties in package accountmgmt 3. Create a sub-class of FSRedirectException and override the constructors. public class FSAccountManagementException extends FSRedirectException { public FSAccountManagementException() { super(); } public FSAccountManagementException(String msg) { super(msg); } public FSAccountManagementException(String msg, Throwable t) { super(msg,t); } Throwing/Catching Exception Examples: ------------------------------------ 1. Throwing a non-nested Exception (not recommended, use Ex. 3 below) FSRedirectException ux = new FSRedirectException("Some weird error!..."); throw ux; 2. Throwing a nested Exception (not recommended, use Ex. 3 below) try { ....... ....... } catch (UMSException umse) { FSRedirectException fse = new FSRedirectException("Some weird error!...", le); throw ux; } 3. Throwing an Exception using the ResourceSetManager- Logging/Dealing with an Exception, inclunding all nested exceptions try { ....... ....... } catch (FSRedirectException fse) { if (fse.getRootCause() instanceof UMSException) { PrintWriter pw = new PrintWriter( ); fse.log(pw); } else { System.out.println(fse.getMessage()); } }
Modifier and Type | Field and Description |
---|---|
protected String |
_message
Deprecated.
|
protected Throwable |
rootCause
Deprecated.
|
Constructor and Description |
---|
FSRedirectException(Exception ex)
Deprecated.
Constructor
Constructs a
FSRedirectException with an exception. |
FSRedirectException(String message)
Deprecated.
Constructor
Constructs a
FSRedirectException with a detailed message. |
FSRedirectException(String errorCode,
Object[] args)
Deprecated.
Constructor
|
FSRedirectException(String errorCode,
Object[] args,
Throwable rootCause)
Deprecated.
Constructor
|
FSRedirectException(Throwable rootCause,
String message)
Deprecated.
Constructor
Constructs a
FSRedirectException with a message and
an embedded exception. |
Modifier and Type | Method and Description |
---|---|
Throwable |
getRootCause()
Deprecated.
Returns the embedded exception.
|
PrintWriter |
log(PrintWriter out)
Deprecated.
Formats this
FSRedirectException to a
PrintWriter . |
static PrintWriter |
log(Throwable xcpt,
PrintWriter out)
Deprecated.
Formats an Exception to a
PrintWriter . |
void |
printStackTrace()
Deprecated.
Prints this exception's stack trace to System.err.
|
void |
printStackTrace(PrintStream ps)
Deprecated.
Prints this exception's stack trace to a print stream.
|
void |
printStackTrace(PrintWriter pw)
Deprecated.
Prints this exception's stack trace to a print writer.
|
String |
toString()
Deprecated.
Returns a formatted
FSRedirectException exception message;
includes embedded exceptions. |
getErrorCode, getL10NMessage, getMessage, getMessageArgs, getResourceBundleName
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace
protected String _message
protected Throwable rootCause
public FSRedirectException(String errorCode, Object[] args)
errorCode
- Key of the error message in resource bundle.args
- Arguments to the message.public FSRedirectException(String errorCode, Object[] args, Throwable rootCause)
errorCode
- Key of the error message in resource bundle.args
- Arguments to the message.rootCause
- An embedded exceptionpublic FSRedirectException(String message)
FSRedirectException
with a detailed message.message
- Detailed message for this exception.public FSRedirectException(Throwable rootCause, String message)
FSRedirectException
with a message and
an embedded exception.message
- Detailed message for this exception.rootCause
- An embedded exceptionpublic FSRedirectException(Exception ex)
FSRedirectException
with an exception.ex
- Exceptionpublic Throwable getRootCause()
public PrintWriter log(PrintWriter out)
FSRedirectException
to a
PrintWriter
.out
- PrintWriter
to write exception to.PrintWriter
public static PrintWriter log(Throwable xcpt, PrintWriter out)
PrintWriter
.xcpt
- Exception
to log.out
- PrintWriter
to write exception to.PrintWriter
public String toString()
FSRedirectException
exception message;
includes embedded exceptions.public void printStackTrace()
printStackTrace
in class Throwable
public void printStackTrace(PrintStream ps)
printStackTrace
in class Throwable
ps
- The non-null print stream to which to print.public void printStackTrace(PrintWriter pw)
printStackTrace
in class Throwable
pw
- The non-null print writer to which to print.Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.