共用方式為


CommandLineBuilderExtensions.UseExceptionHandler 方法

定義

讓例外狀況處理程式在叫用期間攔截命令處理程序擲回的任何未處理的例外狀況。

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

參數

builder
CommandLineBuilder

命令行產生器。

onException
Action<Exception,InvocationContext>

命令處理程序擲回例外狀況時所呼叫的委派。

errorExitCode
Nullable<Int32>

擲回例外狀況時要使用的結束代碼。

傳回

的相同實例 CommandLineBuilder

適用於