failed static method
void
failed(})
Reports operation failure with enhanced error information.
Displays an error message followed by optional suggestions and examples, and terminates the application with a red "FAILED" indicator.
Parameters:
message: Primary error message to displaysuggestion: Optional suggestion for resolving the errorexamples: Optional list of example commands to fix the issueisExit: Whether to exit the process (default: true)statusExit: Exit code to use (default: 1)
Example:
StatusHelper.failed(
'Configuration file not found',
suggestion: 'Run "morpheme init" to create a new configuration file',
examples: ['morpheme init', 'morpheme config'],
);
// Output: (in red text)
// Configuration file not found
//
// Suggestion: Run "morpheme init" to create a new configuration file
//
// Example commands:
// morpheme init
// morpheme config
//
// FAILED
Implementation
static void failed(
String message, {
String? suggestion,
List<String>? examples,
bool isExit = true,
int statusExit = 1,
}) {
printerrMessage(red(message));
if (suggestion != null) {
printerrMessage(yellow('\nSuggestion: $suggestion'));
}
if (examples != null && examples.isNotEmpty) {
printerrMessage(cyan('\nExample commands:'));
for (final example in examples) {
printerrMessage(cyan(' $example'));
}
}
printerrMessage(red('\nFAILED'));
if (isExit) {
exit(statusExit);
}
}