Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Add a custom configuration exception
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalijr2 committed Nov 6, 2024
1 parent b02b9f6 commit 3f8a31c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3f8a31c

Please sign in to comment.