2023-02-16 10:17:08 +08:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2024-07-22 09:43:48 +02:00
|
|
|
|
2023-02-16 10:17:08 +08:00
|
|
|
part 'error.freezed.dart';
|
|
|
|
part 'error.g.dart';
|
|
|
|
|
|
|
|
@freezed
|
2024-06-25 01:59:38 +02:00
|
|
|
class AIError with _$AIError {
|
|
|
|
const factory AIError({
|
2023-02-16 10:17:08 +08:00
|
|
|
required String message,
|
2024-07-22 09:43:48 +02:00
|
|
|
@Default(AIErrorCode.other) AIErrorCode code,
|
2024-06-25 01:59:38 +02:00
|
|
|
}) = _AIError;
|
2023-02-16 10:17:08 +08:00
|
|
|
|
2024-06-25 01:59:38 +02:00
|
|
|
factory AIError.fromJson(Map<String, Object?> json) =>
|
|
|
|
_$AIErrorFromJson(json);
|
2023-02-16 10:17:08 +08:00
|
|
|
}
|
2024-07-22 09:43:48 +02:00
|
|
|
|
|
|
|
enum AIErrorCode {
|
|
|
|
@JsonValue('AIResponseLimitExceeded')
|
|
|
|
aiResponseLimitExceeded,
|
|
|
|
@JsonValue('Other')
|
|
|
|
other,
|
|
|
|
}
|
|
|
|
|
|
|
|
extension AIErrorExtension on AIError {
|
|
|
|
bool get isLimitExceeded => code == AIErrorCode.aiResponseLimitExceeded;
|
|
|
|
}
|