diff --git a/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerConfigurationException.java b/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerConfigurationException.java new file mode 100644 index 0000000..01cb5c3 --- /dev/null +++ b/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerConfigurationException.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Vitalij Berdinskih + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.github.vitalijr2.mock.jdk.platform.logging; + +/** + * If configuration is invalid or there is IO exception. + */ +public class MockLoggerConfigurationException extends RuntimeException { + + public MockLoggerConfigurationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinder.java b/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinder.java index db4dc64..e2905cb 100644 --- a/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinder.java +++ b/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinder.java @@ -127,7 +127,7 @@ static InputStream fallbackInputStream() { return properties; } catch (IllegalArgumentException | IOException exception) { - throw new RuntimeException("Could not load configuration properties", exception); + throw new MockLoggerConfigurationException("Could not load configuration properties", exception); } } diff --git a/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinderSlowTest.java b/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinderSlowTest.java index a817bf1..442eade 100644 --- a/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinderSlowTest.java +++ b/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockLoggerFinderSlowTest.java @@ -91,7 +91,8 @@ void inputOutputException() throws IOException { when(fallbackInputStream.read(isA(byte[].class))).thenThrow(new IOException("test exception")); // when - var exception = assertThrows(RuntimeException.class, () -> MockLoggerFinder.loadProperties("qwerty.properties")); + var exception = assertThrows(MockLoggerConfigurationException.class, + () -> MockLoggerFinder.loadProperties("qwerty.properties")); // then assertAll("IOException is thrown",