renderCommand<T extends Object> method
Future<OutputContext>
renderCommand<T extends Object>(
- CommandOutput output, {
- required Operation<
T> operation, - required OutputWidget textOutputUi,
- OutputWidget? fallbackErrorUi,
Implementation
Future<OutputContext> renderCommand<T extends Object>(
final CommandOutput output, {
required final Operation<T> operation,
required final OutputWidget textOutputUi,
final OutputWidget? fallbackErrorUi,
}) async {
final exceptionHandlingUi = CommonClientExceptionsWidget(
baseCommand: baseCommand,
elseWidget: ExceptionHandlingWidget<FailureException>(
errorWidgetMaker: (final e) => FailureExceptionWidget(e),
elseWidget: fallbackErrorUi,
),
);
final ui = CommandWidget.text(
textOutputUi: textOutputUi,
textErrorUi: exceptionHandlingUi,
);
final context = await output.render(operation: operation, ui: ui);
// Re-throw exceptions as appropriate so that Sentry reporting and process exit
// are performed.
final qe = context.find<QualifiedException>();
if (qe != null) {
if (qe.exception case final FailureException f) {
final nested = f.nestedException;
if (nested != null) {
throw UnexpectedErrorExitException(
f.reason,
nested,
f.nestedStackTrace,
);
}
throw ErrorExitException(f.reason, null, f.nestedStackTrace);
}
Error.throwWithStackTrace(qe.exception, qe.stackTrace);
}
return context;
}