Skip to content

Commit

Permalink
improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
azahnen committed Nov 6, 2024
1 parent ee67410 commit 2d533a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,25 @@ public static Result preCheck(Map<String, String> parameters, LdproxyCfg ldproxy

if (parameters.containsKey("featureProviderType")
&& parameters.get("featureProviderType").equals("PGIS")
&& parameters.containsKey("host")
&& parameters.get("host").isBlank()) {
&& (!parameters.containsKey("host") || parameters.get("host").isBlank())) {
return Result.failure("Host is required for PGIS connection");
}

if (parameters.containsKey("featureProviderType")
&& parameters.get("featureProviderType").equals("WFS")) {
if (!parameters.containsKey("url") || parameters.get("url").isBlank()) {
return Result.failure("URL is required for WFS connection");
}
try {
URI uri = URI.create(parameters.get("url"));
if (!Objects.equals(uri.getScheme(), "http") && !Objects.equals(uri.getScheme(), "https")) {
return Result.failure("Invalid URL scheme for WFS connection");
}
} catch (IllegalArgumentException e) {
return Result.failure("Invalid URL for WFS connection");
}
}

return Result.empty();
}

Expand Down
4 changes: 4 additions & 0 deletions libxtracfg/js/xtracfg/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ const parseError = (response: Response): Error | undefined => {
return { fields: { id: error } };
} else if (message.includes("url")) {
return { fields: { url: message } };
} else if (message.includes("URL")) {
return { fields: { url: message } };
}

if (
(!message.includes("host") &&
!message.includes("Host") &&
!message.includes("url") &&
!message.includes("URL") &&
!message.includes("database") &&
!message.includes("user") &&
!message.includes("password")) ||
Expand Down

0 comments on commit 2d533a0

Please sign in to comment.