Creating a Failure
Let's create a couple of Failure objects that describes the possible errors of the note feature.
Under the note_app/modules/domain/lib/note/failures/
directory, create the following Failure
objects:
1. Create a Failure indicating that the note title has exceeded the max length
Make a file named note_title_too_long_failure.dart
and add the following code:
import 'package:domain/domain.dart';
import 'package:domain/note/entities/note_entry.dart';
/// {@template NoteTitleTooLongFailure}
/// A failure representing a [NoteEntry.title] that has exceeded the maximum
/// length.
/// {@endtemplate}
class NoteTitleTooLongFailure extends Failure {
/// {@macro NoteTitleTooLongFailure}
const NoteTitleTooLongFailure({super.message = 'The note title is too long'});
}
2. Create a Failure indicating that the note content has exceeded the max length
Make a file named and note_content_too_long_failure.dart
add the following code:
import 'package:domain/domain.dart';
import 'package:domain/note/entities/note_entry.dart';
/// {@template NoteContentTooLongFailure}
/// A failure representing a [NoteEntry.content] that has exceeded the maximum
/// length.
/// {@endtemplate}
class NoteContentTooLongFailure extends Failure {
/// {@macro NoteContentTooLongFailure}
const NoteContentTooLongFailure({
super.message = 'The note content is too long',
});
}
Last updated