Skip to content

Commit

Permalink
Now I'm at least starting to like it
Browse files Browse the repository at this point in the history
  • Loading branch information
kniazkov committed Jun 28, 2024
1 parent 43bcec5 commit 6e6ab95
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cqfn.astranaut.core.exceptions;
package org.cqfn.astranaut.core.base;

/**
* Helper class for custom exceptions in projects that use the core as a dependency.
*
* @since 1.0.2
*/
public abstract class BaseException extends Exception {
private static final long serialVersionUID = -636126348743667929L;
public abstract class CoreException extends Exception {
/**
* Version identifier.
*/
private static final long serialVersionUID = -1;

/**
* Returns initiator name, i.e. module that thrown the exception.
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/org/cqfn/astranaut/core/exceptions/package-info.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import java.io.File;
import java.io.IOException;
import org.cqfn.astranaut.core.base.Tree;
import org.cqfn.astranaut.core.exceptions.WrongFileExtension;
import org.cqfn.astranaut.core.utils.visualizer.DotGenerator;
import org.cqfn.astranaut.core.utils.visualizer.ImageRender;
import org.cqfn.astranaut.core.utils.visualizer.WrongFileExtension;

/**
* Visualizer of trees.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import org.cqfn.astranaut.core.exceptions.WrongFileExtension;

/**
* Renders an image from a tree using the external Graphviz tool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cqfn.astranaut.core.exceptions;
package org.cqfn.astranaut.core.utils.visualizer;

import org.cqfn.astranaut.core.base.CoreException;

/**
* Exception "The file extension must be .png or .svg".
*
* @since 1.0.2
*/
public final class WrongFileExtension extends BaseException {
public final class WrongFileExtension extends CoreException {
/**
* The instance.
*/
public static final WrongFileExtension INSTANCE = new WrongFileExtension();

private static final long serialVersionUID = -1780936046129839285L;
/**
* Version identifier.
*/
private static final long serialVersionUID = -1;

@Override
public String getInitiator() {
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/org/cqfn/astranaut/core/base/DiffNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.cqfn.astranaut.core.example.LittleTrees;
import org.cqfn.astranaut.core.example.green.GreenFactory;
import org.cqfn.astranaut.core.exceptions.BaseException;
import org.cqfn.astranaut.core.utils.FilesReader;
import org.cqfn.astranaut.core.utils.JsonDeserializer;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -223,8 +222,8 @@ private String getFileContent(final String name) {
String source = "";
try {
source = new FilesReader(file).readAsString(
(FilesReader.CustomExceptionCreator<BaseException>) ()
-> new BaseException() {
(FilesReader.CustomExceptionCreator<CoreException>) ()
-> new CoreException() {
private static final long serialVersionUID = -8921455132545245481L;

@Override
Expand All @@ -241,7 +240,7 @@ public String getErrorMessage() {
}
}
);
} catch (final BaseException exception) {
} catch (final CoreException exception) {
oops = true;
}
Assertions.assertFalse(oops);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import org.cqfn.astranaut.core.base.CoreException;
import org.cqfn.astranaut.core.base.Factory;
import org.cqfn.astranaut.core.base.Node;
import org.cqfn.astranaut.core.base.Tree;
Expand All @@ -34,7 +35,6 @@
import org.cqfn.astranaut.core.example.green.Addition;
import org.cqfn.astranaut.core.example.green.GreenFactory;
import org.cqfn.astranaut.core.example.green.IntegerLiteral;
import org.cqfn.astranaut.core.exceptions.BaseException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -129,8 +129,8 @@ private String getFileContent(final String name) {
String source = "";
try {
source = new FilesReader(file).readAsString(
(FilesReader.CustomExceptionCreator<BaseException>) ()
-> new BaseException() {
(FilesReader.CustomExceptionCreator<CoreException>) ()
-> new CoreException() {
private static final long serialVersionUID = -6130330765091840343L;

@Override
Expand All @@ -147,7 +147,7 @@ public String getErrorMessage() {
}
}
);
} catch (final BaseException exception) {
} catch (final CoreException exception) {
oops = true;
}
Assertions.assertFalse(oops);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.cqfn.astranaut.core.base.DraftNode;
import org.cqfn.astranaut.core.base.EmptyTree;
import org.cqfn.astranaut.core.base.Tree;
import org.cqfn.astranaut.core.exceptions.WrongFileExtension;
import org.cqfn.astranaut.core.utils.visualizer.WrongFileExtension;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
Expand Down

0 comments on commit 6e6ab95

Please sign in to comment.