Edit

Share via


CommandLineBuilderExtensions.UseExceptionHandler Method

Definition

Enables an exception handler to catch any unhandled exceptions thrown by a command handler during invocation.

public static System.CommandLine.Builder.CommandLineBuilder UseExceptionHandler (this System.CommandLine.Builder.CommandLineBuilder builder, Action<Exception,System.CommandLine.Invocation.InvocationContext>? onException = default, int? errorExitCode = default);
static member UseExceptionHandler : System.CommandLine.Builder.CommandLineBuilder * Action<Exception, System.CommandLine.Invocation.InvocationContext> * Nullable<int> -> System.CommandLine.Builder.CommandLineBuilder
<Extension()>
Public Function UseExceptionHandler (builder As CommandLineBuilder, Optional onException As Action(Of Exception, InvocationContext) = Nothing, Optional errorExitCode As Nullable(Of Integer) = Nothing) As CommandLineBuilder

Parameters

builder
CommandLineBuilder

A command line builder.

onException
Action<Exception,InvocationContext>

A delegate that will be called when an exception is thrown by a command handler.

errorExitCode
Nullable<Int32>

The exit code to be used when an exception is thrown.

Returns

The same instance of CommandLineBuilder.

Applies to