michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * Catching system exceptions of different types with try statement michael@0: * michael@0: * @path ch12/12.14/S12.14_A19_T1.js michael@0: * @description Testing try/catch syntax construction michael@0: */ michael@0: michael@0: // CHECK#1 michael@0: try{ michael@0: throw (Error("hello")); michael@0: } michael@0: catch(e){ michael@0: if (e.toString()!=="Error: hello") $ERROR('#1: Exception.toString()==="Error: hello". Actual: Exception is '+e); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: try{ michael@0: throw (new Error("hello")); michael@0: } michael@0: catch(e){ michael@0: if (e.toString()!=="Error: hello") $ERROR('#2: Exception.toString()==="Error: hello". Actual: Exception is '+e); michael@0: } michael@0: michael@0: // CHECK#3 michael@0: var c3=0; michael@0: try{ michael@0: throw EvalError(1); michael@0: } michael@0: catch(e){ michael@0: if (e.toString()!=="EvalError: 1") $ERROR('#3: Exception.toString()==="EvalError: 1". Actual: Exception is '+e); michael@0: } michael@0: michael@0: // CHECK#4 michael@0: try{ michael@0: throw RangeError(1); michael@0: } michael@0: catch(e){ michael@0: if (e.toString()!=="RangeError: 1") $ERROR('#4: Exception.toString()==="RangeError: 1". Actual: Exception is '+e); michael@0: } michael@0: michael@0: // CHECK#5 michael@0: try{ michael@0: throw ReferenceError(1); michael@0: } michael@0: catch(e){ michael@0: if (e.toString()!=="ReferenceError: 1") $ERROR('#5: Exception.toString()==="ReferenceError: 1". Actual: Exception is '+e); michael@0: } michael@0: michael@0: // CHECK#6 michael@0: var c6=0; michael@0: try{ michael@0: throw TypeError(1); michael@0: } michael@0: catch(e){ michael@0: if (e.toString()!=="TypeError: 1") $ERROR('#6: Exception.toString()==="TypeError: 1". Actual: Exception is '+e); michael@0: } michael@0: michael@0: // CHECK#7 michael@0: try{ michael@0: throw URIError("message", "fileName", "1"); michael@0: } michael@0: catch(e){ michael@0: if (e.toString()!=="URIError: message") $ERROR('#7: Exception.toString()==="URIError: message". Actual: Exception is '+e); michael@0: } michael@0: