Skip to content

Commit

Permalink
fixed OnInvokeError error类型不正确
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack authored and Jack committed Aug 25, 2020
1 parent 24ee95a commit bbd6d3d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions JMS.ServiceProvider/Impls/InvokeRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Extensions.DependencyInjection;
using JMS.Dtos;
using System.Linq;
using System.Reflection;

namespace JMS.Impls
{
Expand Down Expand Up @@ -202,6 +203,9 @@ public void Handle(NetClient netclient, InvokeCommand cmd)
}
catch (Exception ex)
{
if (ex is TargetInvocationException && ex.InnerException != null)
ex = ex.InnerException;

if (transactionDelegate != null)
{
try
Expand All @@ -218,6 +222,7 @@ public void Handle(NetClient netclient, InvokeCommand cmd)
}
transactionDelegate = null;
}

try
{
if( controller?.OnInvokeError(cmd.Method, parameters, ex) == false)
Expand Down
2 changes: 1 addition & 1 deletion JMS.ServiceProvider/JMS.ServiceProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>JMS.ServiceProvider</AssemblyName>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/simpleway2016/JMS</RepositoryUrl>
<Version>1.0.1.2</Version>
<Version>1.0.1.3</Version>
<Authors>Jack.T</Authors>
<Company>JMS</Company>
<Product>JMS</Product>
Expand Down
12 changes: 11 additions & 1 deletion JMS.TestServiceHost/Controller1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Security.Authentication;
using System.Text;

namespace JMS
Expand Down Expand Up @@ -59,7 +60,16 @@ public long IntTest()

public string ErrTest()
{
throw new Exception("ErrTest异常啦");
throw new AuthenticationException("ErrTest异常啦");
}

public override bool OnInvokeError(string actionName, object[] parameters, Exception error)
{
if( error is AuthenticationException)
{
return true;
}
return false;
}
}
}
1 change: 1 addition & 0 deletions TestApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static void Main(string[] args)
Thread.Sleep(1000);
controller1 = tran.GetMicroService<Controller1>();
}

var Service2 = tran.GetMicroService("Service2");

var ret = controller1.Test(123, "Jack.T");
Expand Down

0 comments on commit bbd6d3d

Please sign in to comment.