如何将字符串变量传递给OnExceptionAspect

时间:2012-02-25 22:28:06

标签: postsharp

我希望使用自定义字符串在OnExceptionAspect中使用。

假设我创建了一个名为“message”的字符串,然后在:

Method A: message = "Could not record your personal data"
Method B: message = "Could not record your date of birth" etc.

然后,在OnExceptionAspect中,字符串将从抛出异常的方法中获取,并将其包含在结果消息框中或其他任何内容中,例如:

If(MethodThatThrewException) has string "message";
  exceptionMessage = (MethodThatThrewExption).message;

以上是否可行或是否有其他方法可以做到这一点。

1 个答案:

答案 0 :(得分:0)

我决定将变量作为参数传递给方面更容易,例如......

[ExceptionDialog(null, "This is my custom message")]
相关问题