mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: optimaze error code
This commit is contained in:
parent
ef0d59ff30
commit
7950f8170b
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user