Atitit. js javascript exception Handling Mechanism and java exception conversion. js exception process Voae, atitit. jsvoae

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.