chore: on no courses found for language, log error (#4434)
This commit is contained in:
parent
16be5684f9
commit
34fb8614c1
3 changed files with 29 additions and 4 deletions
|
|
@ -1,10 +1,12 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/constants/local.key.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
class Environment {
|
||||
static bool get itIsTime =>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/course_plans/courses/course_filter.dart';
|
||||
import 'package:fluffychat/pangea/course_plans/courses/course_plan_model.dart';
|
||||
import 'package:fluffychat/pangea/course_plans/courses/course_plans_repo.dart';
|
||||
|
|
@ -40,8 +41,22 @@ mixin CourseSearchProvider<T extends StatefulWidget> on State<T> {
|
|||
});
|
||||
final resp = await CoursePlansRepo.searchByFilter(filter: _filter);
|
||||
courses = resp.coursePlans;
|
||||
if (courses.isEmpty) {
|
||||
ErrorHandler.logError(
|
||||
e: "No courses found",
|
||||
data: {
|
||||
'filter': _filter.toJson(),
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (e, s) {
|
||||
debugPrint("Failed to load courses: $e\n$s");
|
||||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: {
|
||||
'filter': _filter.toJson(),
|
||||
},
|
||||
);
|
||||
error = e;
|
||||
} finally {
|
||||
if (mounted) setState(() => loading = false);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,14 @@ class CourseFilter {
|
|||
return where;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"targetLanguage": targetLanguage?.toJson(),
|
||||
"languageOfInstructions": languageOfInstructions?.toJson(),
|
||||
"cefrLevel": cefrLevel?.string,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue