Class UpgradeException

  • All Implemented Interfaces:
    java.io.Serializable

    public class UpgradeException
    extends java.lang.IllegalArgumentException
    UpgradeException - Documentation.

    If there are exceptions when performing an upgrade, this exception will throw.
    See Also:
    Serialized Form




    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method
      static void checkFileExistsAndCanAccess​(String fileOrDirectoryName, String fileOrDirectoryTypeMessage)
      static void checkFileIsWriteable​(String fileName, String fileTypeMessage, String initStr)
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.

        Note that Java's java.lang.Exception and java.lang.Error classes implement the Serializable interface, and a warning-free build expects this field be defined here.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        1
        public static final long serialVersionUID = 1;
        
    • Constructor Detail

      • UpgradeException

        public UpgradeException()
        Constructs an UpgradeException with no detail message.
      • UpgradeException

        public UpgradeException​(java.lang.String message)
        Constructs an UpgradeException with the specified detail message.
        Parameters:
        message - the detail message.
      • UpgradeException

        public UpgradeException​(java.lang.String message,
                                java.lang.Throwable cause)
        Constructs a new exception with the specified detail message and cause.

        NOTE: The detail message associated with cause is not automatically incorporated in this exception's detail message.
        Parameters:
        message - The detail message (which is saved for later retrieval by the Throwable.getMessage() method).
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
      • UpgradeException

        public UpgradeException​(java.lang.Throwable cause)
        Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for exceptions that are little more than wrappers for other throwables.
        Parameters:
        cause - The cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
    • Method Detail

      • checkFileExistsAndCanAccess

        public static void checkFileExistsAndCanAccess​
                    (java.lang.String fileOrDirectoryName,
                     java.lang.String fileOrDirectoryTypeMessage)
        
        Simple error checking to ensure that a file exists, and that it is accessible.
        Parameters:
        fileOrDirectoryName - This is the file (or directory) to be checked for existence and security privileges.
        fileOrDirectoryTypeMessage - This message will be used in error or exception messages if the check fails.
        Throws:
        UpgradeException - If there are any problems loading the file, or reading from it, then this exception will throw.
        JavaDocError - This will throw if Java throws a serious error. This is unlikely, but given that file-system problems should be dealt with immediately, if they occur, catching Java Error's is taken seriously here.
        Code:
        Exact Method Body:
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
         UpgradeException oops = null;
        
         try
         {
             if (! ((new java.io.File(fileOrDirectoryName)).exists()))
                 oops = new UpgradeException(
                     fileOrDirectoryTypeMessage + " does not exist, or is not found:\n" +
                     "[" + fileOrDirectoryName + "]"
                 );
         } 
                
         catch (SecurityException ex)
         {
             throw new UpgradeException(
                 "Unable to access " + fileOrDirectoryTypeMessage + '\n' +
                 "[" + fileOrDirectoryName + "]\ndue to a Java SecurityException.\n" +
                 "Please see getCause() Throwable for Details.", ex
             );
         }
        
         catch (Throwable t)
         {
             throw new JavaDocError(
                 "There was an Error attempting to access" + fileOrDirectoryTypeMessage + '\n' +
                 "[" + fileOrDirectoryName + "]\ndue to a Java Throw.\n" +
                 "Please see getCause() Throwable for Details.", t
             );
         }
        
         if (oops != null) throw oops;
        
      • checkFileIsWriteable

        public static void checkFileIsWriteable​(java.lang.String fileName,
                                                java.lang.String fileTypeMessage,
                                                java.lang.String initStr)
        Simple error checking to ensure that write access is available to a file-name.
        Parameters:
        fileName - This is the file to be checked for write-access privileges.
        fileTypeMessage - This message will be used in error or exception messages if the check fails.
        initStr - This is the initialization string to write to the file. This parameter may be null, and if it is an empty string will be written.
        Throws:
        UpgradeException - If there are any problems writing to the file, then this exception will throw.
        JavaDocError - This will throw if Java throws a serious error. This is unlikely, but given that file-system problems should be dealt with immediately, if they occur, catching Java Error's is taken seriously here.
        Code:
        Exact Method Body:
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
         UpgradeException oops = null;
        
         try
             { FileRW.writeFile((initStr != null) ? initStr : "", fileName); }
        
         catch (SecurityException ex)
         {
             throw new UpgradeException(
                 "Unable to write " + fileTypeMessage + ":\n" + fileName + '\n' +
                 "due to a Java SecurityException.\n" +
                 "Please see getCause() Throwable for Details.", ex
             );
         }
        
         catch (Exception ex)
         {
             throw new UpgradeException(
                 "Unable to write " + fileTypeMessage + ":\n" + fileName + '\n' +
                 "due to a Java Exception.\n" +
                 "Please see getCause() Throwable for Details.", ex
             );
         } 
                
         catch (Error err)
         {
             throw new JavaDocError(
                 "Unable to write " + fileTypeMessage + ":\n" + fileName + '\n' +
                 "due to a Java Error.\n" +
                 "Please see getCause() Throwable for Details.", err
             );
         }