mismatch method

  1. @override
dynamic mismatch(
  1. String jsonPath,
  2. String expected, [
  3. Object? actual
])

Create an exception to throw if the JSON object at jsonPath fails to match the API definition of expected.

Implementation

@override
dynamic mismatch(String jsonPath, String expected, [Object? actual]) {
  var buffer = StringBuffer();
  buffer.write('Expected ');
  buffer.write(expected);
  if (actual != null) {
    buffer.write(' found "');
    buffer.write(json.encode(actual));
    buffer.write('"');
  }
  buffer.write(' at ');
  buffer.write(jsonPath);
  return Exception(buffer.toString());
}