Skip to content

Commit a15f693

Browse files
committed
Fixes exception handling for HTTPGet function.
1 parent cc1e462 commit a15f693

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

structr-base/src/main/java/org/structr/web/function/HttpGetFunction.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.jsoup.nodes.Document;
2626
import org.jsoup.nodes.Element;
2727
import org.jsoup.select.Elements;
28+
import org.structr.common.error.FrameworkException;
2829
import org.structr.core.GraphObjectMap;
2930
import org.structr.core.property.*;
3031
import org.structr.rest.common.HttpHelper;
@@ -56,7 +57,7 @@ public String getSignature() {
5657
}
5758

5859
@Override
59-
public Object apply(final ActionContext ctx, final Object caller, final Object[] sources) {
60+
public Object apply(final ActionContext ctx, final Object caller, final Object[] sources) throws FrameworkException {
6061

6162
if (sources != null && sources.length >= 1 && sources.length <= 4 && sources[0] != null) {
6263

@@ -159,20 +160,12 @@ public Object apply(final ActionContext ctx, final Object caller, final Object[]
159160
}
160161

161162
return response;
162-
} catch (Throwable t) {
163+
} catch (IllegalArgumentException e) {
163164

164-
if (t.getCause() instanceof UnknownHostException) {
165-
166-
logger.warn("{}", t.getMessage());
167-
168-
} else {
169-
170-
logException(caller, t, sources);
171-
}
165+
logParameterError(caller, sources, e.getMessage(), ctx.isJavaScriptContext());
166+
return usage(ctx.isJavaScriptContext());
172167
}
173-
174-
return "";
175-
168+
176169
} else {
177170

178171
logParameterError(caller, sources, ctx.isJavaScriptContext());

structr-base/src/main/java/org/structr/web/function/UiFunction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@
3434
*/
3535
public abstract class UiFunction extends Function<Object, Object> {
3636

37-
protected Map<String, Object> getFromUrl(final ActionContext ctx, final String requestUrl, final String charset, final String username, final String password) throws IOException, FrameworkException {
37+
protected Map<String, Object> getFromUrl(final ActionContext ctx, final String requestUrl, final String charset, final String username, final String password) throws FrameworkException {
3838

3939
return HttpHelper.get(requestUrl, charset, username, password, ctx.getHeaders(), ctx.isValidateCertificates());
4040
}
4141

42-
protected Map<String, Object> getBinaryFromUrl(final ActionContext ctx, final String requestUrl, final String charset, final String username, final String password) throws IOException, FrameworkException {
42+
protected Map<String, Object> getBinaryFromUrl(final ActionContext ctx, final String requestUrl, final String charset, final String username, final String password) throws FrameworkException {
4343

4444
return HttpHelper.getBinary(requestUrl, charset, username, password, ctx.getHeaders(), ctx.isValidateCertificates());
4545
}
4646

47-
protected Map<String, Object> headFromUrl(final ActionContext ctx, final String requestUrl, final String username, final String password) throws IOException, FrameworkException {
47+
protected Map<String, Object> headFromUrl(final ActionContext ctx, final String requestUrl, final String username, final String password) throws FrameworkException {
4848

4949
return HttpHelper.head(requestUrl, password, username, ctx.getHeaders(), ctx.isValidateCertificates());
5050
}

0 commit comments

Comments
 (0)