Comment on page
Creating a Failure
Make sure that the
Failure
objects extend the base Failure
class of the codenic_exception_converter package. Later, this will give us access to utility tools for conveniently converting Exceptions
into Failures
.Under the
note_app/modules/domain/lib/note/failures/
directory, create the following Failure
objects: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'});
}
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 modified 11mo ago