Skip to content

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

@MAliM1988

Description

@MAliM1988

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions