Skip to content

Commit 3dfe22e

Browse files
committed
Capture & use "PrintExit" event handler
1 parent ad300e3 commit 3dfe22e

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/DocoptNet/Docopt.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,10 @@ public static IEnumerable<Pattern> GetFlatPatterns(string doc)
211211

212212
protected void OnPrintExit(string doc, int errorCode = 0)
213213
{
214-
if (PrintExit == null)
215-
{
216-
throw new DocoptExitException(doc);
217-
}
214+
if (PrintExit is { } handler)
215+
handler(this, new PrintExitEventArgs(doc, errorCode));
218216
else
219-
{
220-
PrintExit(this, new PrintExitEventArgs(doc, errorCode));
221-
}
217+
throw new DocoptExitException(doc);
222218
}
223219

224220
/// <summary>

0 commit comments

Comments
 (0)