@@ -75,7 +75,7 @@ func (ctx *jsonpathCtx) evalOperation(
75
75
case jsonpath .OpPlus , jsonpath .OpMinus :
76
76
return ctx .evalUnaryArithmetic (op , jsonValue )
77
77
default :
78
- panic ( errors .AssertionFailedf ("unhandled operation type" ) )
78
+ return nil , errors .AssertionFailedf ("unhandled operation type" )
79
79
}
80
80
}
81
81
@@ -98,7 +98,7 @@ func (ctx *jsonpathCtx) evalBoolean(
98
98
case jsonpath .OpStartsWith :
99
99
return ctx .evalPredicate (op , jsonValue , evalStartsWithFunc , true /* evalRight */ , false /* unwrapRight */ )
100
100
default :
101
- panic ( errors .AssertionFailedf ("unhandled operation type" ) )
101
+ return jsonpathBoolUnknown , errors .AssertionFailedf ("unhandled operation type" )
102
102
}
103
103
}
104
104
@@ -224,7 +224,7 @@ func (ctx *jsonpathCtx) evalLogical(
224
224
}
225
225
return jsonpathBoolTrue , nil
226
226
default :
227
- panic ( errors .AssertionFailedf ("unhandled logical operation type" ) )
227
+ return jsonpathBoolUnknown , errors .AssertionFailedf ("unhandled logical operation type" )
228
228
}
229
229
230
230
rightOp , ok := op .Right .(jsonpath.Operation )
@@ -247,7 +247,7 @@ func (ctx *jsonpathCtx) evalLogical(
247
247
}
248
248
return rightBool , nil
249
249
default :
250
- panic ( errors .AssertionFailedf ("unhandled logical operation type" ) )
250
+ return jsonpathBoolUnknown , errors .AssertionFailedf ("unhandled logical operation type" )
251
251
}
252
252
}
253
253
@@ -359,7 +359,7 @@ func evalComparisonFunc(operation jsonpath.Operation, l, r json.JSON) (jsonpathB
359
359
// Don't evaluate non-scalar types.
360
360
return jsonpathBoolUnknown , nil
361
361
default :
362
- panic ( errors .AssertionFailedf ("unhandled json type" ) )
362
+ return jsonpathBoolUnknown , errors .AssertionFailedf ("unhandled json type" )
363
363
}
364
364
365
365
var res bool
@@ -377,7 +377,7 @@ func evalComparisonFunc(operation jsonpath.Operation, l, r json.JSON) (jsonpathB
377
377
case jsonpath .OpCompGreaterEqual :
378
378
res = cmp >= 0
379
379
default :
380
- panic ( errors .AssertionFailedf ("unhandled jsonpath comparison type" ) )
380
+ return jsonpathBoolUnknown , errors .AssertionFailedf ("unhandled jsonpath comparison type" )
381
381
}
382
382
if res {
383
383
return jsonpathBoolTrue , nil
@@ -473,7 +473,7 @@ func performArithmetic(
473
473
}
474
474
_ , err = tree .DecimalCtx .Rem (& res , leftNum , rightNum )
475
475
default :
476
- panic ( errors .AssertionFailedf ("unhandled jsonpath arithmetic type" ) )
476
+ return nil , errors .AssertionFailedf ("unhandled jsonpath arithmetic type" )
477
477
}
478
478
if err != nil {
479
479
return nil , err
0 commit comments