Class UpgradeException

    • Field Summary

       
      Serializable ID
      Modifier and Type Field
      static long serialVersionUID
    • Constructor Summary

      Constructors 
      Constructor Description
      UpgradeException()
      Constructs an UpgradeException with no detail message.
      UpgradeException​(String message)
      Constructs an UpgradeException with the specified detail message.
      UpgradeException​(String message, Throwable cause)
      Constructs a new exception with the specified detail message and cause.
      UpgradeException​(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).
    • Method Summary

       
      'static' Exception Check 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:
         public static final long serialVersionUID = 1;
        
    • Constructor Detail

      • 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 into 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:
         try
         {
             if (! ((new java.io.File(fileOrDirectoryName)).exists()))
        
                 throw new UpgradeException(
                     fileOrDirectoryTypeMessage + " does not exist, or is not found:\n" +
                     "[" + fileOrDirectoryName + "]"
                 );
         } 
        
         catch (UpgradeException ue) { throw ue; }
        
         catch (Exception e)
         {
             throw new UpgradeException(
                 "There was an Error attempting to access" + fileOrDirectoryTypeMessage + '\n' +
                 "[" + fileOrDirectoryName + "]\n"+
                 "due to a(n) [" + e.getClass().getSimpleName() + "] throw.\n" +
                 "Please see Throwable.getCause() for Details.", e
             );
         }
        
      • 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.
        Code:
        Exact Method Body:
         try
             { FileRW.writeFile((initStr != null) ? initStr : "", fileName); }
        
         catch (Exception e)
         {
             throw new UpgradeException(
                 "Unable to write " + fileTypeMessage + ":\n" + fileName + '\n' +
                 "due to a(n) [" + e.getClass().getSimpleName() + "] throw.\n" +
                 "Please see Throwable.getCause() for Details.", e
             );
         }