Skip to content

Commit

Permalink
handle exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Jul 5, 2024
1 parent 41fddec commit 4cbc742
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.vavr.control.Either;
import io.vavr.control.Option;

import java.io.UnsupportedEncodingException;
import java.util.*;

import static io.vavr.API.Left;
Expand Down Expand Up @@ -136,7 +137,11 @@ public void evaluate(Deque<Term> stack, Map<Long, Term> variables, TemporarySymb
if(s.isEmpty()) {
throw new Error.Execution("string not found in symbols for id"+value);
} else {
stack.push(new Term.Integer(s.get().getBytes("UTF-8").length));
try {
stack.push(new Term.Integer(s.get().getBytes("UTF-8").length));
} catch (UnsupportedEncodingException e) {
throw new Error.Execution("cannot calculate string length: "+e.toString());
}
}
} else if (value instanceof Term.Bytes) {
stack.push(new Term.Integer(((Term.Bytes) value).value().length));
Expand Down

0 comments on commit 4cbc742

Please sign in to comment.