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.

660 B
Raw Blame
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,
    required 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;
}