Browse Source

Log controller and action name on errors

pull/14557/head
Halil İbrahim Kalkan 4 years ago
parent
commit
42caea5821
  1. 90
      framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs

90
framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs

@ -112,60 +112,68 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
protected virtual void ConfigureClientProxySelector(ControllerModel controller, ActionModel action)
{
RemoveEmptySelectors(action.Selectors);
var remoteServiceAtt = ReflectionHelper.GetSingleAttributeOrDefault<RemoteServiceAttribute>(action.ActionMethod);
if (remoteServiceAtt != null && !remoteServiceAtt.IsEnabledFor(action.ActionMethod))
try
{
return;
}
RemoveEmptySelectors(action.Selectors);
var actionApiDescriptionModel = FindActionApiDescriptionModel(controller, action);
if (actionApiDescriptionModel == null)
{
Logger.LogWarning($"Could not find ApiDescriptionModel for action: {action.ActionName} in controller: {controller.ControllerName}, May be the generate-proxy.json is not up to date.");
return;;
}
ControllerWithAttributeRoute.Add(controller);
ActionWithAttributeRoute.Add(action);
if (!action.Selectors.Any())
{
var abpServiceSelectorModel = new SelectorModel
var remoteServiceAtt = ReflectionHelper.GetSingleAttributeOrDefault<RemoteServiceAttribute>(action.ActionMethod);
if (remoteServiceAtt != null && !remoteServiceAtt.IsEnabledFor(action.ActionMethod))
{
AttributeRouteModel = new AttributeRouteModel(new RouteAttribute(template: actionApiDescriptionModel.Url)),
ActionConstraints = { new HttpMethodActionConstraint(new[] { actionApiDescriptionModel.HttpMethod }) }
};
return;
}
action.Selectors.Add(abpServiceSelectorModel);
}
else
{
foreach (var selector in action.Selectors)
var actionApiDescriptionModel = FindActionApiDescriptionModel(controller, action);
if (actionApiDescriptionModel == null)
{
var httpMethod = selector.ActionConstraints
.OfType<HttpMethodActionConstraint>()
.FirstOrDefault()?
.HttpMethods?
.FirstOrDefault();
Logger.LogWarning($"Could not find ApiDescriptionModel for action: {action.ActionName} in controller: {controller.ControllerName}, May be the generate-proxy.json is not up to date.");
return;;
}
if (httpMethod == null)
{
httpMethod = actionApiDescriptionModel.HttpMethod;
}
ControllerWithAttributeRoute.Add(controller);
ActionWithAttributeRoute.Add(action);
if (selector.AttributeRouteModel == null)
if (!action.Selectors.Any())
{
var abpServiceSelectorModel = new SelectorModel
{
selector.AttributeRouteModel = new AttributeRouteModel(new RouteAttribute(template: actionApiDescriptionModel.Url));
}
AttributeRouteModel = new AttributeRouteModel(new RouteAttribute(template: actionApiDescriptionModel.Url)),
ActionConstraints = { new HttpMethodActionConstraint(new[] { actionApiDescriptionModel.HttpMethod }) }
};
if (!selector.ActionConstraints.OfType<HttpMethodActionConstraint>().Any())
action.Selectors.Add(abpServiceSelectorModel);
}
else
{
foreach (var selector in action.Selectors)
{
selector.ActionConstraints.Add(new HttpMethodActionConstraint(new[] { httpMethod }));
var httpMethod = selector.ActionConstraints
.OfType<HttpMethodActionConstraint>()
.FirstOrDefault()?
.HttpMethods?
.FirstOrDefault();
if (httpMethod == null)
{
httpMethod = actionApiDescriptionModel.HttpMethod;
}
if (selector.AttributeRouteModel == null)
{
selector.AttributeRouteModel = new AttributeRouteModel(new RouteAttribute(template: actionApiDescriptionModel.Url));
}
if (!selector.ActionConstraints.OfType<HttpMethodActionConstraint>().Any())
{
selector.ActionConstraints.Add(new HttpMethodActionConstraint(new[] { httpMethod }));
}
}
}
}
catch
{
Logger.LogError($"An exception has occured while configuring client proxy selector. Controller: {controller.ControllerName} ({controller.ControllerType.AssemblyQualifiedName}), Action: {action.ActionName}");
throw;
}
}
protected virtual void ConfigureClientProxyApiExplorer(ControllerModel controller)

Loading…
Cancel
Save