CommandLineBuilderExtensions.UseExceptionHandler Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
Returns
The same instance of CommandLineBuilder.
Applies to
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.