mardi 24 avril 2018

Diference betwen Exception Handling and Async Exception handling

I create Web API app and don't understand how my Global Exception Handling works. This don't work.

public void Handle(ExceptionHandlerContext context){
if (context.Exception is ObjectNotFoundException)
        //    {
        //        var result = new HttpResponseMessage(HttpStatusCode.NotFound)
        //        {
        //            Content = new StringContent(context.Exception.Message),
        //            ReasonPhrase = "Nothing here for you"
        //        };
        //        context.Result = new ObjectNotFoundException(context.Request, result);
        //    }}

And this work fine

 public override void Handle(ExceptionHandlerContext context){
    if (context.Exception is ObjectNotFoundException)
            //    {
            //        var result = new HttpResponseMessage(HttpStatusCode.NotFound)
            //        {
            //            Content = new StringContent(context.Exception.Message),
            //            ReasonPhrase = "Nothing here for you"
            //        };
            //        context.Result = new ObjectNotFoundException(context.Request, result);
            //    }}




Aucun commentaire:

Enregistrer un commentaire