2012-02-04 38 views
1

我試圖使用@Catch註釋來捕獲在我的應用程序中生成的任何JAXB UnmarshalExceptions。我試着用在Play Documentation@Catch描述代碼:Play Framework 1.2.4:使用@Catch註釋時的IllegalArgumentException

@Catch(UnmarshalException.class) 
    public static void addUnmarshalError() {...} 

@Catch(value = UnmarshalException.class, priority = 1) 
    public static void addUnmarshalError() {...} 

但既不工程。

每一個我用的標註時間我得到的消息:

Oops: IllegalArgumentException 
An unexpected error occured caused by exception IllegalArgumentException: wrong number of arguments 

我不認爲這是該方法中的代碼,因爲即使是空的方法體生成異常。在我的@Catch電話中是否缺少某些東西?

回答

2

你的方法應該採取Throwable作爲參數:

@Catch(UnmarshalException.class) 
    public static void addUnmarshalError(Throwable throwable) {...} 
+0

這正是問題。我在註釋調用中尋找問題,而不是方法簽名。謝謝! – 2012-02-06 16:49:45