I'm running .NET Core 3.1 on macOS, using the dotnet watch
command line to run my web application and unit tests. When my app crashes, the stack trace is frequently so large that I can't see what actually went wrong:
Is there some way I can get the dotnet
command to only show the stack frames from my own code (as opposed to the .NET Core / Entity Framework calls), so I get an error something more like:
Unhandled exception. System.InvalidOperationException: The entity type
'Attendee' requires a primary key to be defined. If you intended
to use a keyless entity type call 'HasNoKey()'.
[...50 non-user stack frames hidden...]
at Website.Program.Main(String[] args) in /code/my-app/Program.cs:line 7
watch : Exited with error code 134
watch : Waiting for a file to change before restarting dotnet...
Failing that - any way to just show, say, the first five lines of the stack trace?
Maybe could be useful just to split
Environment.StackTrace
string and get several lines from the top since the most recent calls go first.