mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-05 07:16:58 +00:00
29 lines
679 B
Dart
29 lines
679 B
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'error.freezed.dart';
|
|
part 'error.g.dart';
|
|
|
|
@freezed
|
|
class AIError with _$AIError {
|
|
const factory AIError({
|
|
required String message,
|
|
@Default(AIErrorCode.other) AIErrorCode code,
|
|
}) = _AIError;
|
|
|
|
factory AIError.fromJson(Map<String, Object?> json) =>
|
|
_$AIErrorFromJson(json);
|
|
}
|
|
|
|
enum AIErrorCode {
|
|
@JsonValue('AIResponseLimitExceeded')
|
|
aiResponseLimitExceeded,
|
|
@JsonValue('AIImageResponseLimitExceeded')
|
|
aiImageResponseLimitExceeded,
|
|
@JsonValue('Other')
|
|
other,
|
|
}
|
|
|
|
extension AIErrorExtension on AIError {
|
|
bool get isLimitExceeded => code == AIErrorCode.aiResponseLimitExceeded;
|
|
}
|