DSL parsing : Catch index out of bound exception (#3364)

* In case index being referred does not exist, throw appropriate error during DSL parsing

* Fixing bad commit.
This commit is contained in:
Trisha Anand 2021-03-03 18:51:35 +05:30 committed by GitHub
parent 639913703a
commit 5e448b9331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -322,7 +322,13 @@ public class LayoutActionServiceImpl implements LayoutActionService {
parent = ((Map<String, ?>) parent).get(nextKey);
} else if (parent instanceof List) {
if (Pattern.matches(Pattern.compile("[0-9]+").toString(), nextKey)) {
parent = ((List) parent).get(Integer.parseInt(nextKey));
try {
parent = ((List) parent).get(Integer.parseInt(nextKey));
} catch (IndexOutOfBoundsException e) {
// The index being referred does not exist. Hence the path would not exist.
throw new AppsmithException(AppsmithError.INVALID_DYNAMIC_BINDING_REFERENCE, widgetType,
widgetName, widgetId, fieldPath, pageId, layoutId);
}
} else {
throw new AppsmithException(AppsmithError.INVALID_DYNAMIC_BINDING_REFERENCE, widgetType,
widgetName, widgetId, fieldPath, pageId, layoutId);