I think what you are looking for is exception developer page.
You can add this middleware
app.UseDeveloperExceptionPage();