Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Replaced Oracle PathException with a custom one
Browse files Browse the repository at this point in the history
  • Loading branch information
Petschko committed May 4, 2019
1 parent 93321bb commit 4884279
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 8 deletions.
158 changes: 158 additions & 0 deletions src/org/petschko/lib/exceptions/PathException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package org.petschko.lib.exceptions;

import java.security.PrivilegedActionException;

/**
* Author: Peter Dragicevic [peter@petschko.org]
* Authors-Website: https://petschko.org/
* Date: 04.05.2019
* Time: 21:03
* Update: -
* Version: 0.0.1
*
* Notes: PathException (Replacement for Oracle-Path-Exception)
*/
public class PathException extends Exception {
private String path;

/**
* Constructs a new throwable with {@code null} as its detail message.
* The cause is not initialized, and may subsequently be initialized by a
* call to {@link #initCause}.
*
* <p>The {@link #fillInStackTrace()} method is called to initialize
* the stack trace data in the newly created throwable.
*
* @param path - Path of the Exception
*/
public PathException(String path) {
super();
this.path = path;
}

/**
* Constructs a new throwable with the specified detail message. The
* cause is not initialized, and may subsequently be initialized by
* a call to {@link #initCause}.
*
* <p>The {@link #fillInStackTrace()} method is called to initialize
* the stack trace data in the newly created throwable.
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
* @param path - Path of the Exception
*/
public PathException(String message, String path) {
super(message);
this.path = path;
}

/**
* Constructs a new throwable with the specified detail message and
* cause. <p>Note that the detail message associated with
* {@code cause} is <i>not</i> automatically incorporated in
* this throwable's detail message.
*
* <p>The {@link #fillInStackTrace()} method is called to initialize
* the stack trace data in the newly created throwable.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param path - Path of the Exception
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public PathException(String message, String path, Throwable cause) {
super(message, cause);
this.path = path;
}

/**
* Constructs a new throwable with the specified cause and a detail
* message of {@code (cause==null ? null : cause.toString())} (which
* typically contains the class and detail message of {@code cause}).
* This constructor is useful for throwables that are little more than
* wrappers for other throwables (for example, {@link
* PrivilegedActionException}).
*
* <p>The {@link #fillInStackTrace()} method is called to initialize
* the stack trace data in the newly created throwable.
*
* @param path - Path of the Exception
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public PathException(String path, Throwable cause) {
super(cause);
this.path = path;
}

/**
* Constructs a new throwable with the specified detail message,
* cause, {@linkplain #addSuppressed suppression} enabled or
* disabled, and writable stack trace enabled or disabled. If
* suppression is disabled, {@link #getSuppressed} for this object
* will return a zero-length array and calls to {@link
* #addSuppressed} that would otherwise append an exception to the
* suppressed list will have no effect. If the writable stack
* trace is false, this constructor will not call {@link
* #fillInStackTrace()}, a {@code null} will be written to the
* {@code stackTrace} field, and subsequent calls to {@code
* fillInStackTrace} and {@link
* #setStackTrace(StackTraceElement[])} will not set the stack
* trace. If the writable stack trace is false, {@link
* #getStackTrace} will return a zero length array.
*
* <p>Note that the other constructors of {@code Throwable} treat
* suppression as being enabled and the stack trace as being
* writable. Subclasses of {@code Throwable} should document any
* conditions under which suppression is disabled and document
* conditions under which the stack trace is not writable.
* Disabling of suppression should only occur in exceptional
* circumstances where special requirements exist, such as a
* virtual machine reusing exception objects under low-memory
* situations. Circumstances where a given exception object is
* repeatedly caught and rethrown, such as to implement control
* flow between two sub-systems, is another situation where
* immutable throwable objects would be appropriate.
*
* @param message the detail message.
* @param path - Path of the Exception
* @param cause the cause. (A {@code null} value is permitted,
* and indicates that the cause is nonexistent or unknown.)
* @param enableSuppression whether or not suppression is enabled or disabled
* @param writableStackTrace whether or not the stack trace should be
* writable
* @see OutOfMemoryError
* @see NullPointerException
* @see ArithmeticException
*/
protected PathException(String message, String path, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
this.path = path;
}

/**
* Gets the Path
*
* @return - Path of the Exception
*/
public String getPath() {
return path;
}

/**
* Returns the detail message string of this throwable.
*
* @return the detail message string of this {@code Throwable} instance
* (which may be {@code null}).
*/
@Override
public String getMessage() {
return super.getMessage() + " | Path: " + this.path;
}
}
6 changes: 3 additions & 3 deletions src/org/petschko/rpgmakermv/decrypt/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import org.petschko.lib.Const;
import org.petschko.lib.File;
import org.petschko.lib.Functions;
import org.petschko.lib.exceptions.PathException;
import org.petschko.lib.gui.*;
import org.petschko.lib.gui.notification.ErrorWindow;
import org.petschko.lib.gui.notification.InfoWindow;
import sun.dc.path.PathException;

import javax.swing.BorderFactory;
import javax.swing.JDialog;
Expand All @@ -30,8 +30,8 @@
* Authors-Website: http://petschko.org/
* Date: 28.12.2016
* Time: 19:14
* Update: 03.02.2017
* Version: 0.1.2
* Update: 04.05.2019
* Version: 0.1.3
*
* Notes: GUI Class
*/
Expand Down
10 changes: 5 additions & 5 deletions src/org/petschko/rpgmakermv/decrypt/RPGProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.sun.istack.internal.NotNull;
import org.json.JSONException;
import org.petschko.lib.File;
import sun.dc.path.PathException;
import org.petschko.lib.exceptions.PathException;
import java.util.ArrayList;

/**
* Author: Peter Dragicevic [peter@petschko.org]
* Authors-Website: http://petschko.org/
* Date: 23.12.2016
* Time: 11:19
* Update: 03.02.2017
* Version: 0.1.1
* Update: 04.05.2019
* Version: 0.1.2
*
* Notes: RPG-Project-Class
*/
Expand All @@ -34,14 +34,14 @@ class RPGProject {
*/
RPGProject(@NotNull String path, boolean verifyRPGDir) throws PathException {
if(! File.existsDir(path))
throw new PathException("Project-Path doesn't exists!");
throw new PathException("Project-Path doesn't exists!", path);

this.setPath(path);

// Check if Path is a Valid-RPG-Maker-Dir
if(verifyRPGDir)
if(! this.verifyDir())
throw new PathException("Directory is not a Valid RPG-Maker-MV Directory!");
throw new PathException("Directory is not a Valid RPG-Maker-MV Directory!", path);

this.loadFiles();
this.findSystemFile();
Expand Down

0 comments on commit 4884279

Please sign in to comment.