Java - Throwable to Exception

后端 未结 5 1189
清酒与你
清酒与你 2021-02-03 20:26

I am currently using the play2 framework.

I have several classes which are throwing exceptions but play2s global onError handler uses throwable

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 21:09

    Can I check a throwable object if it is a NoSessionException ?

    Sure:

    Throwable t = ...;
    if (t instanceof NoSessionException) {
        ...
        // If you need to use information in the exception
        // you can cast it in here
    }
    

提交回复
热议问题