Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reform & Re-throw Exception on OnException Method in IMethodInterceptor #81

Open
MAliM1988 opened this issue Apr 22, 2019 · 0 comments
Open

Comments

@MAliM1988
Copy link

Hello Everyone

I Have Problem With IMethodInterceptor.OnException I Use Cauldron.Interception version 3.2.3 with this code

[InterceptorOptions(AlwaysCreateNewInstance = true)]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class ExceptionInterceptorAttribute : Attribute, IMethodInterceptor, IDisposable
{
	#region Fields

	private Type _declaringType;
	private MethodBase _methodBase;
	private object[] _values;

	#endregion

	#region IMethodInterceptor Members

	public void OnEnter(Type declaringType, object instance, MethodBase methodbase, object[] values)
	{
		_declaringType = declaringType;
		_methodBase = methodbase;
		_values = values;
	}

	public bool OnException(Exception e)
	{
		throw catchHandler(e, _declaringType, _methodBase, _values);
	}

	public void OnExit()
	{

	}

	#endregion

	#region Private Members

	private Exception catchHandler(Exception exception, Type type, MethodBase methodBase, object[] values)
	{
		return new Exception(exception.Message);
	}

	#endregion

	#region IDisposable Members

	public void Dispose()
	{
		_declaringType = null;
		_methodBase = null;
		_values = null;

		GC.SuppressFinalize(this);
	}

	#endregion
}

When i reform exception an re-throw new exception my project debugging has break and project has stopped.

I replace body of OnException with this (re-throw without reform exception)

	public bool OnException(Exception e)
	{
		catchHandler(e, _declaringType, _methodBase, _values);

		return true;
	}

debugging mode is run and back to host of project,how can i reform and re-throw exception with or without return true?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant