From d35d8af63e1dd15c3c49a1d1b5941077fac5094b Mon Sep 17 00:00:00 2001 From: slozenko Date: Tue, 19 Mar 2024 10:47:49 -0700 Subject: [PATCH] replace logging by TemplateError usage --- .../hubspot/jinjava/lib/filter/SliceFilter.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hubspot/jinjava/lib/filter/SliceFilter.java b/src/main/java/com/hubspot/jinjava/lib/filter/SliceFilter.java index 64b9e2a2a..6e1d1a37b 100644 --- a/src/main/java/com/hubspot/jinjava/lib/filter/SliceFilter.java +++ b/src/main/java/com/hubspot/jinjava/lib/filter/SliceFilter.java @@ -1,13 +1,12 @@ package com.hubspot.jinjava.lib.filter; -import static com.hubspot.jinjava.util.Logging.ENGINE_LOG; - import com.hubspot.jinjava.doc.annotations.JinjavaDoc; import com.hubspot.jinjava.doc.annotations.JinjavaParam; import com.hubspot.jinjava.doc.annotations.JinjavaSnippet; import com.hubspot.jinjava.interpret.InvalidArgumentException; import com.hubspot.jinjava.interpret.InvalidReason; import com.hubspot.jinjava.interpret.JinjavaInterpreter; +import com.hubspot.jinjava.interpret.TemplateError; import com.hubspot.jinjava.interpret.TemplateSyntaxException; import com.hubspot.jinjava.util.ForLoop; import com.hubspot.jinjava.util.ObjectIterator; @@ -84,8 +83,17 @@ public Object filter(Object var, JinjavaInterpreter interpreter, String... args) args[0] ); } else if (slices > MAX_SLICES) { - ENGINE_LOG.warn( - "The limit input value is too large, it's been reduced to " + MAX_SLICES + interpreter.addError( + new TemplateError( + TemplateError.ErrorType.WARNING, + TemplateError.ErrorReason.OVER_LIMIT, + TemplateError.ErrorItem.FILTER, + "The limit input value is too large, it's been reduced to " + MAX_SLICES, + null, + interpreter.getLineNumber(), + interpreter.getPosition(), + null + ) ); slices = MAX_SLICES; }