@@ -286,15 +286,18 @@ test("return from nested finally", () => {
286286 expect ( util . transpileAndExecute ( code ) ) . toBe ( "finally AB" ) ;
287287} ) ;
288288
289- test ( "throw and catch custom error object" , ( ) => {
290- util . testFunction `
289+ test . each ( [ `"Hello error string!"` , `42` , `true` , `false` , `undefined` , `{ x: "Hello error object!" }` ] ) (
290+ "throw and catch custom error object" ,
291+ error => {
292+ util . testFunction `
291293 try {
292- throw { x: "Hello error object!" };
294+ throw ${ error } ;
293295 } catch (error) {
294- return error.x ;
296+ return error;
295297 }
296298 ` . expectToMatchJsResult ( ) ;
297- } ) ;
299+ }
300+ ) ;
298301
299302test . each ( [ "Error" , "RangeError" , "ReferenceError" , "SyntaxError" , "TypeError" , "URIError" ] ) (
300303 "throw builtin Errors as classes" ,
@@ -304,7 +307,7 @@ test.each(["Error", "RangeError", "ReferenceError", "SyntaxError", "TypeError",
304307 throw new ${ errorType } ("message")
305308 } catch (error) {
306309 if (error instanceof Error) {
307- return \`\${ error}\` ;
310+ return error.toString() ;
308311 } else {
309312 throw Error("This error serves to prevent false positives from .expectNoExecutionError()");
310313 }
@@ -321,7 +324,7 @@ test.each(["Error", "RangeError", "ReferenceError", "SyntaxError", "TypeError",
321324 throw ${ errorType } ("message")
322325 } catch (error) {
323326 if (error instanceof Error) {
324- return \`\${ error}\` ;
327+ return error.toString() ;
325328 } else {
326329 throw Error("This error serves to prevent false positives from .expectNoExecutionError()");
327330 }
@@ -333,14 +336,14 @@ test.each(["Error", "RangeError", "ReferenceError", "SyntaxError", "TypeError",
333336test ( "subclass Error" , ( ) => {
334337 util . testFunction `
335338 class MyError extends Error {
336- name: "MyError"
339+ public name = "MyError";
337340 }
338341
339342 try {
340343 throw new MyError();
341344 } catch (error) {
342345 if (error instanceof Error) {
343- return \'\$ error\' ;
346+ return error.toString() ;
344347 } else {
345348 throw Error("This error serves to prevent false positives from .expectNoExecutionError()");
346349 }
0 commit comments