Skip to content

Commit 2b31aee

Browse files
dab246hoangdat
authored andcommitted
Add converter for ErrorType
1 parent 42cb0dd commit 2b31aee

File tree

5 files changed

+23
-34
lines changed

5 files changed

+23
-34
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import 'package:jmap_dart_client/jmap/core/error/error_type.dart';
3+
import 'package:json_annotation/json_annotation.dart';
4+
5+
class ErrorTypeConverter implements JsonConverter<ErrorType, String> {
6+
const ErrorTypeConverter();
7+
8+
@override
9+
ErrorType fromJson(String json) => ErrorType(json);
10+
11+
@override
12+
String toJson(ErrorType object) => object.value;
13+
}
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
import 'package:equatable/equatable.dart';
2-
import 'package:json_annotation/json_annotation.dart';
32

4-
part 'error_type.g.dart';
5-
6-
@JsonSerializable()
73
class ErrorType with EquatableMixin {
84
final String value;
95

106
ErrorType(this.value);
117

128
@override
139
List<Object> get props => [value];
14-
15-
factory ErrorType.fromJson(Map<String, dynamic> json) => _$ErrorTypeFromJson(json);
16-
17-
Map<String, dynamic> toJson() => _$ErrorTypeToJson(this);
1810
}

lib/jmap/core/error/error_type.g.dart

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/jmap/core/error/set_error.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import 'package:equatable/equatable.dart';
2+
import 'package:jmap_dart_client/http/converter/error_type_converter.dart';
23
import 'package:jmap_dart_client/jmap/core/error/error_type.dart';
34
import 'package:json_annotation/json_annotation.dart';
45

56
part 'set_error.g.dart';
67

8+
@ErrorTypeConverter()
79
@JsonSerializable(explicitToJson: true)
810
class SetError with EquatableMixin {
911
final ErrorType type;

lib/jmap/core/error/set_error.g.dart

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)