Hello
The env variable is retrieved as a string, and you need to check its value. The IWebHostEnvironment type has a method IsDevelopment() that can be used to check if the environment is set to "Development".
Here is how you can modify your code:
var app = builder.Build();
var env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
app.ConfigureExceptionHandler(env);
In this code snippet, GetRequiredService<IWebHostEnvironment>() retrieves the IWebHostEnvironment service, and then you can use the IsDevelopment() method to check if it's a development environment.
Make sure that your ConfigureExceptionHandler method in ExceptionMiddleWareExtentions takes IWebHostEnvironment as a parameter:
public static void ConfigureExceptionHandler(this IApplicationBuilder app, IWebHostEnvironment env)
{
// Your existing code...
}
This way, you can use the env variable to determine the environment type.