fix
This commit is contained in:
@@ -20,12 +20,13 @@ public class ResponseFilter : IActionFilter
|
||||
|
||||
public void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
var route = $"{context.Controller.GetType().Name}.{context.ActionDescriptor.DisplayName}";
|
||||
if (context.Result == null)
|
||||
throw new NotSupportedException($"Response required");
|
||||
throw new NotSupportedException($"[{route}] Response required");
|
||||
if (!(context.Result is ObjectResult result))
|
||||
throw new NotSupportedException($"Response must be an ObjectResult - {context.Result?.GetType().Name}");
|
||||
throw new NotSupportedException($"[{route}] Response must be an ObjectResult - {context.Result?.GetType().Name}");
|
||||
if (result.Value == null)
|
||||
throw new NotSupportedException($"Response must be an ObjectResult with value");
|
||||
throw new NotSupportedException($"[{route}] Response must be an ObjectResult with value");
|
||||
|
||||
if (result.Value is IResponseModel)
|
||||
{
|
||||
@@ -40,6 +41,6 @@ public class ResponseFilter : IActionFilter
|
||||
return;
|
||||
}
|
||||
|
||||
throw new NotSupportedException($"Response must be an ObjectResult with an IResponseModel - {result.Value?.GetType().Name}");
|
||||
throw new NotSupportedException($"[{route}] Response must be an ObjectResult with an IResponseModel - {result.Value?.GetType().Name}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user