fix: Edge case where MatrixException.error differs from errcode
This commit is contained in:
parent
881f8c3fd8
commit
3cc2f2fa4a
|
|
@ -87,10 +87,11 @@ class MatrixException implements Exception {
|
|||
@override
|
||||
String toString() => '$errcode: $errorMessage';
|
||||
|
||||
/// Returns the [ResponseError]. Is ResponseError.NONE if there wasn't an error.
|
||||
/// Returns the errcode as an [MatrixError].
|
||||
MatrixError get error => MatrixError.values.firstWhere(
|
||||
(e) => e.toString() == 'MatrixError.${(raw["errcode"] ?? "")}',
|
||||
orElse: () => MatrixError.M_UNKNOWN);
|
||||
(e) => e.name == errcode,
|
||||
orElse: () => MatrixError.M_UNKNOWN,
|
||||
);
|
||||
|
||||
int? get retryAfterMs => raw.tryGet<int>('retry_after_ms');
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ void main() {
|
|||
expect(exception.completedAuthenticationFlows, ['example.type.foo']);
|
||||
expect(exception.requireAdditionalAuthentication, true);
|
||||
expect(exception.retryAfterMs, null);
|
||||
expect(exception.error, MatrixError.M_UNKNOWN);
|
||||
expect(exception.error, MatrixError.M_FORBIDDEN);
|
||||
expect(exception.errcode, 'M_FORBIDDEN');
|
||||
expect(exception.errorMessage, 'Require additional authentication');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue