Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bd79cb55
authored
Oct 24, 2012
by
Riku Silvola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
error handling
1 parent
18eb8de1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
code/LanBortalWeb/WebContent/error.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/ErrorPageView.java
code/LanBortalWeb/WebContent/error.xhtml
View file @
bd79cb5
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<title>
Error
</title>
<title>
Error
</title>
</h:head>
</h:head>
<h:body>
<h:body>
<!-- <c:if test="#{sessionHandler.isInDevelopmentMode() eq
tru
e}"> -->
<!-- <c:if test="#{sessionHandler.isInDevelopmentMode() eq
fals
e}"> -->
<h1>
#{i18n['error.error']}
</h1>
<h1>
#{i18n['error.error']}
</h1>
<p>
${i18n['error.contact']}
<p>
${i18n['error.contact']}
<br/><h:outputText
escape=
"false"
style=
"color: red;"
value=
"#{errorPageView.time}"
/><br/><br/>
<br/><h:outputText
escape=
"false"
style=
"color: red;"
value=
"#{errorPageView.time}"
/><br/><br/>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/ErrorPageView.java
View file @
bd79cb5
...
@@ -18,6 +18,8 @@ import java.io.StringWriter;
...
@@ -18,6 +18,8 @@ import java.io.StringWriter;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.zip.CRC32
;
@Named
@Named
@RequestScoped
@RequestScoped
public
class
ErrorPageView
implements
Serializable
{
public
class
ErrorPageView
implements
Serializable
{
...
@@ -34,6 +36,7 @@ public class ErrorPageView implements Serializable {
...
@@ -34,6 +36,7 @@ public class ErrorPageView implements Serializable {
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ErrorPageView
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ErrorPageView
.
class
);
public
String
getStackTrace
()
{
public
String
getStackTrace
()
{
...
@@ -51,14 +54,29 @@ public class ErrorPageView implements Serializable {
...
@@ -51,14 +54,29 @@ public class ErrorPageView implements Serializable {
}
}
public
String
getStackTraceHash
()
{
FacesContext
context
=
FacesContext
.
getCurrentInstance
();
Map
requestMap
=
context
.
getExternalContext
().
getRequestMap
();
Throwable
ex
=
(
Throwable
)
requestMap
.
get
(
"javax.servlet.error.exception"
);
CRC32
stackHash
=
new
CRC32
();
stackHash
.
update
(
ex
.
getStackTrace
().
toString
().
getBytes
());
return
"0x"
+
Long
.
toHexString
(
stackHash
.
getValue
());
}
public
String
getTime
(){
public
String
getTime
(){
return
"0x"
+
Long
.
toHexString
(
Calendar
.
getInstance
().
getTimeInMillis
());
String
stamp
=
"0x"
+
Long
.
toHexString
(
Calendar
.
getInstance
().
getTimeInMillis
());
logger
.
error
(
"Error occured at {} trail {}"
,
stamp
,
getTrail
());
return
stamp
;
}
}
public
String
getTrail
()
{
public
String
getTrail
()
{
HttpServletRequest
req
=
(
HttpServletRequest
)
getContext
().
getExternalContext
().
getRequest
();
HttpServletRequest
req
=
(
HttpServletRequest
)
getContext
().
getExternalContext
().
getRequest
();
Object
trail
=
req
.
getSession
().
getAttribute
(
"trail"
);
Object
trail
=
req
.
getSession
().
getAttribute
(
"trail"
);
return
trail
!=
null
?
trail
.
toString
()
.
replace
(
", "
,
"\n"
)
:
"u gots no trail!
"
;
return
trail
!=
null
?
trail
.
toString
()
:
"
"
;
}
}
public
FacesContext
getContext
()
{
public
FacesContext
getContext
()
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment