Merge pull request #9262 from Maiklins/JAVA-618-split-core-java-exceptions
Java-618 split core java exceptions
This commit is contained in:
commit
dc6f778bfe
|
@ -9,3 +9,6 @@ This module contains articles about core java exceptions
|
||||||
- [java.net.UnknownHostException: Invalid Hostname for Server](https://www.baeldung.com/java-unknownhostexception)
|
- [java.net.UnknownHostException: Invalid Hostname for Server](https://www.baeldung.com/java-unknownhostexception)
|
||||||
- [How to Handle Java SocketException](https://www.baeldung.com/java-socketexception)
|
- [How to Handle Java SocketException](https://www.baeldung.com/java-socketexception)
|
||||||
- [Java Suppressed Exceptions](https://www.baeldung.com/java-suppressed-exceptions)
|
- [Java Suppressed Exceptions](https://www.baeldung.com/java-suppressed-exceptions)
|
||||||
|
- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources)
|
||||||
|
- [Java Global Exception Handler](https://www.baeldung.com/java-global-exception-handler)
|
||||||
|
- [How to Find an Exception’s Root Cause in Java](https://www.baeldung.com/java-exception-root-cause)
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
<version>${assertj-core.version}</version>
|
<version>${assertj-core.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons.lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<description> </description>
|
<description> </description>
|
||||||
|
@ -30,6 +35,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<commons.lang3.version>3.10</commons.lang3.version>
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.rootcausefinder;
|
package com.baeldung.rootcausefinder;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.Period;
|
import java.time.Period;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.exceptions.globalexceptionhandler;
|
package com.baeldung.globalexceptionhandler;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
|
@ -1,7 +1,7 @@
|
||||||
package com.baeldung.exceptions.rootcausefinder;
|
package com.baeldung.rootcausefinder;
|
||||||
|
|
||||||
import com.baeldung.exceptions.rootcausefinder.RootCauseFinder.CalculationException;
|
import com.baeldung.rootcausefinder.RootCauseFinder.CalculationException;
|
||||||
import com.baeldung.exceptions.rootcausefinder.RootCauseFinder.DateOutOfRangeException;
|
import com.baeldung.rootcausefinder.RootCauseFinder.DateOutOfRangeException;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
@ -11,8 +11,7 @@ import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
import static com.baeldung.exceptions.rootcausefinder.RootCauseFinder.AgeCalculator;
|
import static com.baeldung.rootcausefinder.RootCauseFinder.AgeCalculator;
|
||||||
import static com.baeldung.exceptions.rootcausefinder.RootCauseFinder.findCauseUsingPlainJava;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +37,7 @@ public class RootCauseFinderUnitTest {
|
||||||
try {
|
try {
|
||||||
AgeCalculator.calculateAge("010102");
|
AgeCalculator.calculateAge("010102");
|
||||||
} catch (CalculationException ex) {
|
} catch (CalculationException ex) {
|
||||||
assertTrue(findCauseUsingPlainJava(ex) instanceof DateTimeParseException);
|
assertTrue(RootCauseFinder.findCauseUsingPlainJava(ex) instanceof DateTimeParseException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ public class RootCauseFinderUnitTest {
|
||||||
try {
|
try {
|
||||||
AgeCalculator.calculateAge("2020-04-04");
|
AgeCalculator.calculateAge("2020-04-04");
|
||||||
} catch (CalculationException ex) {
|
} catch (CalculationException ex) {
|
||||||
assertTrue(findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException);
|
assertTrue(RootCauseFinder.findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ public class RootCauseFinderUnitTest {
|
||||||
try {
|
try {
|
||||||
AgeCalculator.calculateAge(null);
|
AgeCalculator.calculateAge(null);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException);
|
assertTrue(RootCauseFinder.findCauseUsingPlainJava(ex) instanceof IllegalArgumentException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,5 @@ This module contains articles about core java exceptions
|
||||||
- [“Sneaky Throws” in Java](https://www.baeldung.com/java-sneaky-throws)
|
- [“Sneaky Throws” in Java](https://www.baeldung.com/java-sneaky-throws)
|
||||||
- [The StackOverflowError in Java](https://www.baeldung.com/java-stack-overflow-error)
|
- [The StackOverflowError in Java](https://www.baeldung.com/java-stack-overflow-error)
|
||||||
- [Checked and Unchecked Exceptions in Java](https://www.baeldung.com/java-checked-unchecked-exceptions)
|
- [Checked and Unchecked Exceptions in Java](https://www.baeldung.com/java-checked-unchecked-exceptions)
|
||||||
- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources)
|
|
||||||
- [Java Global Exception Handler](https://www.baeldung.com/java-global-exception-handler)
|
|
||||||
- [Common Java Exceptions](https://www.baeldung.com/java-common-exceptions)
|
- [Common Java Exceptions](https://www.baeldung.com/java-common-exceptions)
|
||||||
- [How to Find an Exception’s Root Cause in Java](https://www.baeldung.com/java-exception-root-cause)
|
|
||||||
- [Is It a Bad Practice to Catch Throwable?](https://www.baeldung.com/java-catch-throwable-bad-practice)
|
|
||||||
- [[Next -->]](/core-java-modules/core-java-exceptions-2)
|
- [[Next -->]](/core-java-modules/core-java-exceptions-2)
|
Loading…
Reference in New Issue