Skip to content

[client] add descriptive error msg #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions http-api/src/main/java/io/avaje/http/api/Generated.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.avaje.http.api;

/**
* Marker for generated code.
*/
import java.lang.annotation.Documented;

/** Marker for generated code. */
@Documented
public @interface Generated {

/**
Expand Down
13 changes: 9 additions & 4 deletions http-client/src/main/java/io/avaje/http/client/DHttpApi.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.avaje.http.client;

import io.avaje.applog.AppLog;
import io.avaje.http.client.HttpClient.GeneratedComponent;
import static java.lang.System.Logger.Level.DEBUG;

import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;

import static java.lang.System.Logger.Level.*;
import io.avaje.applog.AppLog;
import io.avaje.http.client.HttpClient.GeneratedComponent;

/** Service loads the HttpApiProvider for HttpApi. */
final class DHttpApi {
Expand Down Expand Up @@ -37,7 +37,12 @@ <T> void addProvider(Class<T> type, HttpApiProvider<?> apiProvider) {
<T> T provideFor(Class<T> type, HttpClient httpClient) {
final var apiProvider = (HttpApiProvider<T>) providerMap.get(type);
if (apiProvider == null) {
throw new IllegalArgumentException("No registered HttpApiProvider for type: " + type);
throw new IllegalArgumentException(
"No registered HttpApiProvider for type: "
+ type
+ "\nPossible Causes: \n"
+ "1. Missing @Client or @Client.Import annotation.\n"
+ "2. The avaje-http-client-generator dependency was not available during compilation\n");
}
return apiProvider.provide(httpClient);
}
Expand Down