Watch
1
0
Fork
You've already forked nexus
0
forked from Nexus/nexus
nexus/lib/models/gomuks_exception.dart

17 lines
543 B
Dart

class GomuksException implements Exception {
final String message;
const GomuksException(this.message);
/// The Matrix error code, if gomuks returned an error in the form `M_CODE (HTTP 404): message`
String? get errorCode =>
RegExp(r"^(M_[A-Z_]+)").firstMatch(message)?.group(1);
/// The HTTP status code of the failed request
int? get statusCode => switch (RegExp(r"HTTP (\d{3})").firstMatch(message)) {
final match? => int.parse(match.group(1)!),
null => null,
};
@override
String toString() => message;
}