Skip to content

Commit

Permalink
Provide actionable error message when RESTEasy Reactive can't pick Pr…
Browse files Browse the repository at this point in the history
…ovider constructor

Relates to: #19750

Co-authored-by: George Gastaldi <[email protected]>
  • Loading branch information
geoand and gastaldi committed Sep 1, 2021
1 parent 469e81a commit 12ca7eb
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,28 @@ public String toString() {

@Override
public BeanInstance<T> createInstance() {
BeanContainer.Instance<T> instance = factory.create();
return new BeanInstance<T>() {
@Override
public T getInstance() {
return instance.get();
BeanContainer.Instance<T> instance;
try {
instance = factory.create();
return new BeanInstance<T>() {
@Override
public T getInstance() {
return instance.get();
}

@Override
public void close() {
instance.close();
}
};
} catch (Exception e) {
if (factory.getClass().getName().contains("DefaultInstanceFactory")) {
throw new IllegalArgumentException(
"Unable to create class '" + targetClassName
+ "'. To fix the problem, make sure this class is a CDI bean.",
e);
}

@Override
public void close() {
instance.close();
}
};
throw e;
}
}
}

0 comments on commit 12ca7eb

Please sign in to comment.