regulaforensics / DocumentReader-Flutter

Flutter plugin for reading and validation of identification documents
MIT License
31 stars 13 forks source link

[BR] Error in JSON response is not always correctly parsed #22

Closed kuhnroyal closed 1 year ago

kuhnroyal commented 1 year ago

Before Submitting, be sure to

Bug Description

When an error on iOS occurs, the JSON response contains keys that are not parsed from the JSON response, resulting in empty error code/message.

Steps To Reproduce

  1. Set wrong/unavailable processing scenario
  2. Try to scan
  3. Inspect the response JSON and the parsed error
{
  "results" : {

  },
  "action" : 4,
  "error" : {
    "localizedDescription" : "Unavailable scenario, please check that your Core type and license support this scenario",
    "code" : 2
  }
}
    final completion = DocumentReaderCompletion.fromJson(json.decode(data))!;

    if (completion.error != null) {
      final message = completion.error!.message; // null
      final errorCode = completion.error!.errorCode; // null
    }

Expected behavior

    final completion = DocumentReaderCompletion.fromJson(json.decode(data))!;

    if (completion.error != null) {
      final message = completion.error!.message; // "Unavailable scenario, please check that your Core type and license support this scenario"
      final errorCode = completion.error!.errorCode; // 2
    }

Environment:

Additional context The code and localizedDescription fields are not parsed here: https://github.com/regulaforensics/DocumentReader-Flutter/blob/master/lib/document_reader.dart#L1552

vyakimchik commented 1 year ago

Hi @kuhnroyal! The issue has been fixed. The fix will be available in the next release version. Thank you!

kuhnroyal commented 1 year ago

Thanks looking forward to the next release!