Java - Throwable to Exception

后端 未结 5 1206
清酒与你
清酒与你 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:07

    In addition to checking if its an instanceof you can use the try catch and catch NoSessionException

    try {
        // Something that throws a throwable
    } catch (NoSessionException e) {
        // Its a NoSessionException 
    } catch (Throwable t) {
        // catch all other Throwables
    }
    

提交回复
热议问题