JScript (sh)F(xin)e(cu)`̎
try { tryStatements} catch(exception){ catchStatements} finally { finallyStatements}
try...catch...finally Z(y)ṩһN(li)̎ܰl(f)ڽoaKеijЩȫe(cu)`ͬr(sh)Աִa\(yn)Сl(f)˳T](mi)̎e(cu)`JScript ֻoÑ(h)ṩͨe(cu)`Ϣͺ](mi)e(cu)`̎һ
tryStatements (sh)ܰl(f)e(cu)`Ĵa catchStatement t̎κΰl(f)˵e(cu)`Ĵa tryStatements аl(f)һ(g)e(cu)`tƱo catchStatements (li)̎exception ijʼֵǰl(f) tryStatements еe(cu)`ֵe(cu)`l(f)t(zh) catchStatements
cl(f)e(cu)` tryStatements P(gun)(lin) catchStatements в̎ԓe(cu)`tʹ throw Z(y)(li)ӳ@(g)e(cu)`o(j)e(cu)`̎
ڈ(zh) tryStatements еZ(y) catchStatements e(cu)`̎l(f)֮ɟo(w)l(zh) finallyStatements еZ(y)䡣
Ո(qng)עʹ try catch Kзһ(g)Z(y) catch Kӳһ(g)e(cu)`Ȼ(hu)(zh) finallyStatements aһ㌢_ finallyStatments \(yn)УǴδ̎e(cu)` catch Kаl(f)\(yn)Еr(sh)e(cu)`
UJScript ̎M(jn)еġ
try { print("Outer try running.."); try { print("Nested try running..."); throw "an error"; } catch(e) { print("Nested catch caught " + e); throw e + " re-thrown"; } finally { print("Nested finally is running..."); } } catch(e) { print("Outer catch caught " + e); } finally { print("Outer finally running"); } // Windows Script Host ԓďĶó WScript.Echo(s) function print(s){ document.write(s); }
ó½Y(ji)
Outer try running.. Nested try running... Nested catch caught an error Nested finally is running... Outer catch caught an error re-thrown Outer finally running