I am using DDMathParser library in my project and I want to use error handling. I want the error to be displayed to user if he inputs wrong expression. What would be my catch block to detect and display related error and its position. Following is my sample code:
do{
var X = "(3 + 4" //Missed Closed Parenthesis
let evaluator = Evaluator()
let expression = try Expression(string: X)
let value = try evaluator.evaluate(expression)
}
catch
{
}
According to DDMathParser it should be Grouping error and by using Range with it it should specify its location where parenthesis got missed or any other error type occurred. Here is its Documentation