Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: optimaze error code

appflowy7950f8170b45
diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart
index a0ba35f9d6..2e70ecddb2 100644
--- a/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart
+++ b/frontend/app_flowy/lib/workspace/application/grid/cell/date_cal_bloc.dart
@@ -1,6 +1,7 @@
import 'package:app_flowy/workspace/application/grid/field/field_service.dart';
import 'package:flowy_sdk/log.dart';
import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
@@ -91,7 +92,7 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
case ErrorCode.InvalidDateTimeFormat:
emit(state.copyWith(
dateData: Some(newDateData),
- timeFormatError: Some(err.toString()),
+ timeFormatError: Some(messageFromFlowyError(err)),
));
break;
default:
@@ -101,6 +102,18 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
);
}
+ String messageFromFlowyError(FlowyError error) {
+ switch (ErrorCode.valueOf(error.code)!) {
+ case ErrorCode.EmailFormatInvalid:
+ return state.copyWith(isSubmitting: false, emailError: some(error.msg), passwordError: none());
+ case ErrorCode.PasswordFormatInvalid:
+ return state.copyWith(isSubmitting: false, passwordError: some(error.msg), emailError: none());
+ default:
+ return state.copyWith(isSubmitting: false, successOrFail: some(right(error)));
+ }
+ return "";
+ }
+
@override
Future<void> close() async {
if (_onCellChangedFn != null) {