Skip to content

Commit 096b531

Browse files
author
Yegor Bugayenko
committed
#355 new ctors for RsFailure
1 parent 8e5af69 commit 096b531

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/main/java/org/takes/facets/forward/RsFailure.java

+33-2
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,34 @@ public class RsFailure extends RsForward {
4646
*/
4747
private static final long serialVersionUID = 396488574468386488L;
4848

49+
/**
50+
* Home page, by default.
51+
*/
52+
private static final String HOME = "/";
53+
4954
/**
5055
* Ctor.
5156
* @param cause Cause
5257
* @throws UnsupportedEncodingException If fails
5358
*/
5459
public RsFailure(final Throwable cause)
60+
throws UnsupportedEncodingException {
61+
this(cause, RsFailure.HOME);
62+
}
63+
64+
/**
65+
* Ctor.
66+
* @param cause Cause
67+
* @param loc Location to redirect to
68+
* @throws UnsupportedEncodingException If fails
69+
* @since 0.21
70+
*/
71+
public RsFailure(final Throwable cause, final CharSequence loc)
5572
throws UnsupportedEncodingException {
5673
super(
5774
new RsFlash(cause),
58-
HttpURLConnection.HTTP_MOVED_PERM
75+
HttpURLConnection.HTTP_MOVED_PERM,
76+
loc
5977
);
6078
}
6179

@@ -65,10 +83,23 @@ public RsFailure(final Throwable cause)
6583
* @throws UnsupportedEncodingException If fails
6684
*/
6785
public RsFailure(final String cause)
86+
throws UnsupportedEncodingException {
87+
this(cause, RsFailure.HOME);
88+
}
89+
90+
/**
91+
* Ctor.
92+
* @param cause Cause
93+
* @param loc Location to redirect to
94+
* @throws UnsupportedEncodingException If fails
95+
* @since 0.21
96+
*/
97+
public RsFailure(final String cause, final CharSequence loc)
6898
throws UnsupportedEncodingException {
6999
super(
70100
new RsFlash(cause),
71-
HttpURLConnection.HTTP_MOVED_PERM
101+
HttpURLConnection.HTTP_MOVED_PERM,
102+
loc
72103
);
73104
}
74105

0 commit comments

Comments
 (0)