Skip to content

Conversation

@abonie
Copy link
Member

@abonie abonie commented May 3, 2023

Fixes: #7677

We shouldn't print a stack trace on fsi.exe internal errors

Before:

# dotnet fsi --foobar


error FS0243: Unrecognized option: '--foobar'

Exception by fsi.exe:
System.Exception: Error creating evaluation session: StopProcessingExn
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1448.Invoke(String message)
   at FSharp.Compiler.Interactive.Shell.FsiCommandLineOptions..ctor(FsiEvaluationSessionHostConfig fsi, String[] argv, TcConfigBuilder tcConfigB, FsiConsoleOutput fsiConsoleOutput) in D:\a\_work\1\s\src\Compiler\Interactive\fsi.fs:line 973
   at FSharp.Compiler.Interactive.Shell.FsiEvaluationSession..ctor(FsiEvaluationSessionHostConfig fsi, String[] argv, TextReader inReader, TextWriter outWriter, TextWriter errorWriter, Boolean fsiCollectible, FSharpOption`1 legacyReferenceResolver) in D:\a\_work\1\s\src\Compiler\Interactive\fsi.fs:line 3411
   at FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.Create(FsiEvaluationSessionHostConfig fsiConfig, String[] argv, TextReader inReader, TextWriter outWriter, TextWriter errorWriter, FSharpOption`1 collectible, FSharpOption`1 legacyReferenceResolver) in D:\a\_work\1\s\src\Compiler\Interactive\fsi.fs:line 3775
   at Sample.FSharp.Compiler.Interactive.Main.evaluateSession@304-1.Invoke(Unit unitVar)
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Sample.FSharp.Compiler.Interactive.Main.evaluateSession(String[] argv) in D:\a\_work\1\s\src\fsi\fsimain.fs:line 304

After:

# .\artifacts\bin\fsi\Debug\net472\fsi.exe --foobar


error FS0243: Unrecognized option: '--foobar'. Use '--help' to learn about recognized command line options.

@abonie abonie force-pushed the stop_printing_stacktrace_fsi branch from 716cf75 to efb8167 Compare May 3, 2023 12:09
@abonie
Copy link
Member Author

abonie commented May 3, 2023

I am actually wondering whether we should display this:

# .\artifacts\bin\fsi\Debug\net472\fsi.exe --foobar


error FS0243: Unrecognized option: '--foobar'

Exception by fsi.exe:
"Error creating evaluation session: StopProcessingExn"

or just this:

# .\artifacts\bin\fsi\Debug\net472\fsi.exe --foobar


error FS0243: Unrecognized option: '--foobar'

edit: changed to the latter already

@abonie abonie marked this pull request as ready for review May 3, 2023 14:37
@abonie abonie requested a review from a team as a code owner May 3, 2023 14:37
@baronfel
Copy link
Member

baronfel commented May 3, 2023

IMO the latter - stack traces for invalid arguments are virtually never useful. We don't show them on the dotnet CLI for this reason. At worst you could consider printing the relevant help usage text, but for FSI that could be quite long.

@abonie
Copy link
Member Author

abonie commented May 3, 2023

At worst you could consider printing the relevant help usage text, but for FSI that could be quite long.

Perhaps just modify the error message to also say Use --help to learn about recognized command line options?

I.e.:

# .\artifacts\bin\fsi\Debug\net472\fsi.exe --foobar


error FS0243: Unrecognized option: '--foobar'. Use --help to learn about recognized command line options.

@abonie abonie force-pushed the stop_printing_stacktrace_fsi branch from b07c19e to efb8167 Compare May 3, 2023 15:30
@psfinaki
Copy link
Contributor

psfinaki commented May 3, 2023

Yep, the help message would be cool.

@abonie abonie enabled auto-merge (squash) May 4, 2023 10:39
@abonie abonie merged commit 9f1afaa into dotnet:main May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

dotnet fsi printing stacktraces on unecognized arguments

5 participants