Catch DB down exception in playframework

穿精又带淫゛_ 提交于 2019-12-06 13:38:05

That Error you can handle in Global.java file in app folder

put a file which Global.java in app folder like this

Global.java file

import play.Application;
import play.GlobalSettings;
import play.libs.F.Promise;
import play.mvc.Result;
import play.mvc.Http.RequestHeader;


public class Global extends GlobalSettings {

    @Override
    public void onStart(Application arg0) {
        // TODO Auto-generated method stub
        super.onStart(arg0);
    }

    @Override
    public void onStop(Application arg0) {
        // TODO Auto-generated method stub
        super.onStop(arg0);
    }
    @Override
    public Promise<Result> onBadRequest(RequestHeader arg0, String arg1) {
        // TODO Auto-generated method stub
        return super.onBadRequest(arg0, arg1);
    }

    @Override
    public Promise<Result> onError(RequestHeader arg0, Throwable arg1) {
        // TODO Auto-generated method stub
        return super.onError(arg0, arg1);
    }


}

in onError method you will receive the Throwable object from the application and can handle it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!