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: quarkusio#19750

Co-authored-by: George Gastaldi <[email protected]>
(cherry picked from commit 12ca7eb)
  • Loading branch information
geoand authored and gsmet committed Sep 6, 2021
1 parent 8ab4886 commit c4981f1
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 c4981f1

Please sign in to comment.