unexpectedResponse method

  1. @override
Never unexpectedResponse(
  1. BaseResponse response,
  2. Uint8List body
)
override

Implementation

@override
Never unexpectedResponse(http.BaseResponse response, Uint8List body) {
  MatrixException? matrixException;
  try {
    matrixException =
        MatrixException.fromJson(json.decode(utf8.decode(body)));
  } catch (_) {} // Is not a MatrixException!

  // Throw MatrixException if response contains 'errcode' (error) or
  // 'session'/'flows' (UIA challenge).
  if (matrixException != null &&
      (matrixException.raw.containsKey('errcode') ||
          matrixException.raw.containsKey('session') ||
          matrixException.raw.containsKey('flows'))) {
    throw matrixException;
  }

  super.unexpectedResponse(response, body);
}