Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
#21: introduced UniJException
Browse files Browse the repository at this point in the history
  • Loading branch information
tlinkowski committed Mar 7, 2019
1 parent db91c8a commit 35e15cb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import pl.tlinkowski.unij.annotation.VisibleForTesting;
import pl.tlinkowski.unij.core.provider.UnmodifiableListFactory;
import pl.tlinkowski.unij.exception.UniJException;

/**
* @author Tomasz Linkowski
Expand All @@ -47,8 +48,8 @@ static <T> T load(Class<T> serviceClass) {

private static <T> void validateLoadedServices(Collection<T> services, Class<T> serviceClass) {
if (services.isEmpty()) {
throw new IllegalStateException(String.format(
"No %s service found. Ensure proper unij-* module is on the classpath/modulepath", serviceClass
throw new UniJException(String.format(
"No %s service found. Ensure proper unij-* module is on the classpath/modulepath", serviceClass.getName()
));
}
log.debug("{} service: found {}", serviceClass.getName(), services);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2019 Tomasz Linkowski.
*
* 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 pl.tlinkowski.unij.exception;

/**
* Dedicated unchecked exception for UniJ.
*
* @author Tomasz Linkowski
*/
public class UniJException extends RuntimeException {

public UniJException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package pl.tlinkowski.unij.core

import spock.lang.Specification

import pl.tlinkowski.unij.exception.UniJException

/**
* @author Tomasz Linkowski
*/
Expand All @@ -29,7 +31,7 @@ class UniJSpec extends Specification {
when:
UniJ.load(ServiceWithoutImpl)
then:
thrown(IllegalStateException)
thrown(UniJException)
}

private static interface ServiceWithoutImpl {
Expand Down

0 comments on commit 35e15cb

Please sign in to comment.