chore: more specific error message on not found course with code (#4336)

This commit is contained in:
ggurdin 2025-10-10 15:32:15 -04:00 committed by GitHub
parent 9ffb9abb9b
commit ff85fc8a9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:collection/collection.dart';
import 'package:get_storage/get_storage.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/l10n/l10n.dart';
@ -17,6 +18,8 @@ import 'package:fluffychat/pangea/spaces/widgets/too_many_requests_dialog.dart';
import 'package:fluffychat/widgets/future_loading_dialog.dart';
import '../../common/controllers/base_controller.dart';
class NotFoundException implements Exception {}
class SpaceCodeController extends BaseController {
late PangeaController _pangeaController;
static final GetStorage _spaceStorage = GetStorage('class_storage');
@ -87,11 +90,19 @@ class SpaceCodeController extends BaseController {
if (knockResult.roomIds.isEmpty &&
knockResult.alreadyJoined.isEmpty &&
!knockResult.rateLimited) {
throw notFoundError ?? L10n.of(context).unableToFindRoom;
throw NotFoundException();
}
return knockResult;
},
onError: (e, s) {
if (e is NotFoundException ||
e is StreamedResponse && e.statusCode == 400) {
return L10n.of(context).unableToFindRoom;
}
return e;
},
);
if (resp.isError || resp.result == null) {