diff --git a/core-java-modules/core-java-exceptions-4/README.md b/core-java-modules/core-java-exceptions-4/README.md index ccc40f3858..9bd5d4b9bb 100644 --- a/core-java-modules/core-java-exceptions-4/README.md +++ b/core-java-modules/core-java-exceptions-4/README.md @@ -8,4 +8,5 @@ This module contains articles about core java exceptions - [Convert long to int Type in Java](https://www.baeldung.com/java-convert-long-to-int) - [“Sneaky Throws” in Java](https://www.baeldung.com/java-sneaky-throws) - [Get the Current Stack Trace in Java](https://www.baeldung.com/java-get-current-stack-trace) +- [Errors and Exceptions in Java](https://www.baeldung.com/java-errors-vs-exceptions) - [[<-- Prev]](../core-java-exceptions-3) diff --git a/core-java-modules/core-java-exceptions-4/src/main/java/com/baeldung/exception/exceptions_vs_errors/ErrorExample.java b/core-java-modules/core-java-exceptions-4/src/main/java/com/baeldung/exception/exceptions_vs_errors/ErrorExample.java index 143ca8c57e..904877e01e 100644 --- a/core-java-modules/core-java-exceptions-4/src/main/java/com/baeldung/exception/exceptions_vs_errors/ErrorExample.java +++ b/core-java-modules/core-java-exceptions-4/src/main/java/com/baeldung/exception/exceptions_vs_errors/ErrorExample.java @@ -1,14 +1,9 @@ package com.baeldung.exception.exceptions_vs_errors; public class ErrorExample { - - public static void main(String[] args) { - overflow(); - } - public static void overflow() { - System.out.println("overflow..."); - overflow(); + public static void main(String[] args) { + throw new AssertionError(); } } diff --git a/core-java-modules/core-java-exceptions-4/src/test/java/com/baeldung/exception/exceptions_vs_errors/ErrorExampleUnitTest.java b/core-java-modules/core-java-exceptions-4/src/test/java/com/baeldung/exception/exceptions_vs_errors/ErrorExampleUnitTest.java index 9fca24638d..acbb07be1f 100644 --- a/core-java-modules/core-java-exceptions-4/src/test/java/com/baeldung/exception/exceptions_vs_errors/ErrorExampleUnitTest.java +++ b/core-java-modules/core-java-exceptions-4/src/test/java/com/baeldung/exception/exceptions_vs_errors/ErrorExampleUnitTest.java @@ -3,11 +3,11 @@ package com.baeldung.exception.exceptions_vs_errors; import org.junit.Test; import org.junit.jupiter.api.Assertions; -// Unit test for the ErrorExample class. public class ErrorExampleUnitTest { + @Test public void whenMainMethodIsRun_thenStackOverflowError() { - Assertions.assertThrows(StackOverflowError.class, - () -> ErrorExample.main(null)); + Assertions.assertThrows(AssertionError.class, + () -> ErrorExample.main(null)); } }