Application unhandled exceptions localization

后端 未结 2 434
孤城傲影
孤城傲影 2021-01-24 08:42

I am trying to display error messages in locale language and for all handled exceptions my team is using resource file to display in local language but Is there a way to interce

2条回答
  •  误落风尘
    2021-01-24 09:08

    Near the start of our app we have a line of code that looks similar to

        config.Services.Replace(typeof(IExceptionHandler), new UnhandledExceptionHandler());
    

    and this seems to catch errors.

    We also have a catch-all route at the end of our route tables that looks a bit like

            config.Routes.MapHttpRoute(
                name: "NotImplemented",
                routeTemplate: "{*data}",
                defaults: new { controller = "Error", action = "notimplemented", data = UrlParameter.Optional });
    

    where we call the same code. You can check the Accept-Language header to make your best guess at what locale your caller might be able to use. Re-post a specific question if you need help with that aspect.

提交回复
热议问题