Atitit. js javascript exception Handling Mechanism and java exception conversion. js exception process Voae, atitit. jsvoae
Atitit. js javascript exception Handling Mechanism and java exception conversion. js exception process Voae
1. javascript Exception Handling Mechanism 1
2. unified handling of Web Front and back-end exceptions 1
3. java exception conversion to js exception 1
3. ------------- detailed code 2
1. javascript Exception Handling Mechanism
Throw str
Not throw error .. cause ie, ff error obj is diff ..
2. unified handling of Web Front and back-end exceptions
If no java exception is converted to a js exception, go to OK...
Dwr has seen abnormal conversion of dwr. 3. It does not take effect... so we have to output str for conversion...
Author: old wow's paw Attilax iron, EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://blog.csdn.net/attilax
3. java exception conversion to js exception
ElmtC. fileChangeEvent ($ ("# filePath"). val (), function (data)
{
ProcessJavaEX (data );
Var plt_s = secs2str (data. Duration );
$ ('# Playtime'). timespinner ('setvalue', plt_s );
});
3. ------------- detailed code
If (NoSetAwd (activityId )){
RuntimeException e = new RuntimeException ("e: noSetAwdErr no prize set for this activity .");
String s = JSONObject. toJSONString (e );
Return s;
}
// {"@ Type": "java. lang. runtimeException "," localizedMessage ":" e: noSetAwdErr no prizes have been set for this activity. "," message ":" e: noSetAwdErr. No prize has been set for this activity. "," stackTrace ": [{" className ":" com. focustar. servlet. awardServlet "," fileName ":" AwardServlet. java "," lineNumber ": 132," methodName ":" main "," nativeMethod ": false}]," suppressed ": []}
Function logx (msg ){
Try {
Console.info ("---------- from logx ");
Console.info ("--" + msg );
} Catch (e ){
// Not support console method (ex: IE)
}
}
Function processJavaEX (data)
{
If (typeof data = "string ")
Data = eval ("(" + data + ")");
If (data ["@ type"]! = Null & data ["@ type"] = "java. lang. RuntimeException ")
{
If (data. message! = Null)
Logx (data. message );
Throw data. message;
}
If (data ["stackTrace"]! = Null)
{
If (data. message! = Null)
Logx (data. message );
Throw data. message;
}
Else
Return false;
}
Reference
Atititjs javascript exception Handling Mechanism and java exception conversion. js exception process-attilax column-blog channel-CSDN.NET.htm