本文整理汇总了Java中org.takes.facets.fallback.RqFallback类的典型用法代码示例。如果您正苦于以下问题:Java RqFallback类的具体用法?Java RqFallback怎么用?Java RqFallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RqFallback类属于org.takes.facets.fallback包,在下文中一共展示了RqFallback类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: route
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
@Override
public final Opt<Response> route(final RqFallback req) throws IOException {
return new Opt.Single<>(
new RsWithStatus(
new RsHtml(
new RsVelocity(
TkApp.class.getResource("error.html.vm"),
new RsVelocity.Pair(
"err",
new TextOf(req.throwable()).asString()
),
new RsVelocity.Pair(
"rev",
Manifests.read("Rehttp-Revision")
)
)
),
HttpURLConnection.HTTP_INTERNAL_ERROR
)
);
}
示例2: fatal
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
/**
* Make fatal error page.
* @param req Request
* @return Response
* @throws IOException If fails
*/
private static Response fatal(final RqFallback req) throws IOException {
return new RsWithStatus(
new RsHtml(
new RsVelocity(
TkApp.class.getResource("error.html.vm"),
new RsVelocity.Pair(
"err",
new TextOf(req.throwable()).asString()
),
new RsVelocity.Pair("rev", TkApp.REV)
)
),
HttpURLConnection.HTTP_INTERNAL_ERROR
);
}
示例3: fatal
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
/**
* Make fatal error page.
* @param req Request
* @return Response
* @throws IOException If fails
*/
private static Response fatal(final RqFallback req) throws IOException {
return new RsWithStatus(
new RsWithType(
new RsVelocity(
TkAppFallback.class.getResource("error.html.vm"),
new RsVelocity.Pair(
"err",
ExceptionUtils.getStackTrace(req.throwable())
),
new RsVelocity.Pair("rev", TkAppFallback.REV)
),
"text/html"
),
HttpURLConnection.HTTP_INTERNAL_ERROR
);
}
示例4: fatal
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
/**
* Make fatal error page.
* @param req Request
* @return Response
* @throws IOException If fails
*/
private static Response fatal(final RqFallback req) throws IOException {
return new RsWithStatus(
new RsWithType(
new RsVelocity(
TkAppFallback.class.getResource("error.html.vm"),
new RsVelocity.Pair(
"err",
ExceptionUtils.getStackTrace(req.throwable())
),
new RsVelocity.Pair("rev", TkAppFallback.REV),
new RsVelocity.Pair("version", TkAppFallback.VERSION)
),
"text/html"
),
HttpURLConnection.HTTP_INTERNAL_ERROR
);
}
示例5: FbError
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
/**
* Ctor.
*/
public FbError() {
super(
new Fallback() {
@Override
public Opt<Response> route(final RqFallback req) {
final String exc = ExceptionUtils.getStackTrace(
req.throwable()
);
return new Opt.Single<Response>(
new RsWithStatus(
new RsText(
String.format(
"oops, something went wrong!\n%s",
exc
)
),
req.code()
)
);
}
}
);
}
示例6: displaysErrorMsg
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
/**
* FbError can display error message.
* @throws IOException If unsuccessful.
*/
@Test
public void displaysErrorMsg() throws IOException {
final String msg = "errormsg";
final Opt<Response> opt = new FbError().route(
new RqFallback.Fake(500, new IOException(msg))
);
MatcherAssert.assertThat(opt.has(), Matchers.equalTo(true));
MatcherAssert.assertThat(
IOUtils.toString(opt.get().body()),
Matchers.allOf(
Matchers.containsString("oops, something "),
Matchers.containsString("IOException"),
Matchers.containsString(msg)
)
);
}
示例7: fatal
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
/**
* Make a fatal response.
* @param req Request
* @return Response
* @throws IOException If fails
*/
private static Response fatal(final RqFallback req) throws IOException {
final String err = ExceptionUtils.getStackTrace(
req.throwable()
);
Logger.error(TkAppFallback.class, "%[exception]s", req.throwable());
return new RsWithStatus(
new RsWithType(
new RsVelocity(
TkAppFallback.class.getResource("error.html.vm"),
new RsVelocity.Pair("error", err),
new RsVelocity.Pair("version", TkAppFallback.VERSION)
),
"text/html"
),
HttpURLConnection.HTTP_INTERNAL_ERROR
);
}
示例8: fatal
import org.takes.facets.fallback.RqFallback; //导入依赖的package包/类
private static Response fatal(final RqFallback req) {
return new RsWithStatus(
new RsText(ExceptionUtils.getStackTrace(req.throwable())),
HttpURLConnection.HTTP_INTERNAL_ERROR
);
}