@@ -263,8 +263,8 @@ try test("Closure Lifetime") {
263
263
let c1Line = #line + 1
264
264
let c1 = JSClosure { $0 [ 0 ] }
265
265
c1. release ( )
266
- let error = try expectThrow ( try evalClosure. throws ( c1, JSValue . number ( 42.0 ) ) ) as! JSValue
267
- try expect ( " Error message should contains definition location " , error. description. hasSuffix ( " PrimaryTests/main.swift: \( c1Line) " ) )
266
+ let error = try expectThrow ( try evalClosure. throws ( c1, JSValue . number ( 42.0 ) ) ) as! JSException
267
+ try expect ( " Error message should contains definition location " , error. thrownValue . description. hasSuffix ( " PrimaryTests/main.swift: \( c1Line) " ) )
268
268
}
269
269
#endif
270
270
@@ -275,8 +275,8 @@ try test("Closure Lifetime") {
275
275
276
276
do {
277
277
let c1 = JSClosure { _ in fatalError ( " Crash while closure evaluation " ) }
278
- let error = try expectThrow ( try evalClosure. throws ( c1) ) as! JSValue
279
- try expectEqual ( error. description, " RuntimeError: unreachable " )
278
+ let error = try expectThrow ( try evalClosure. throws ( c1) ) as! JSException
279
+ try expectEqual ( error. thrownValue . description, " RuntimeError: unreachable " )
280
280
}
281
281
}
282
282
@@ -770,32 +770,32 @@ try test("Exception") {
770
770
771
771
// MARK: Throwing method calls
772
772
let error1 = try expectThrow ( try prop_9. object!. throwing. func1!( ) )
773
- try expectEqual ( error1 is JSValue , true )
774
- let errorObject = JSError ( from: error1 as! JSValue )
773
+ try expectEqual ( error1 is JSException , true )
774
+ let errorObject = JSError ( from: ( error1 as! JSException ) . thrownValue )
775
775
try expectNotNil ( errorObject)
776
776
777
777
let error2 = try expectThrow ( try prop_9. object!. throwing. func2!( ) )
778
- try expectEqual ( error2 is JSValue , true )
779
- let errorString = try expectString ( error2 as! JSValue )
778
+ try expectEqual ( error2 is JSException , true )
779
+ let errorString = try expectString ( ( error2 as! JSException ) . thrownValue )
780
780
try expectEqual ( errorString, " String Error " )
781
781
782
782
let error3 = try expectThrow ( try prop_9. object!. throwing. func3!( ) )
783
- try expectEqual ( error3 is JSValue , true )
784
- let errorNumber = try expectNumber ( error3 as! JSValue )
783
+ try expectEqual ( error3 is JSException , true )
784
+ let errorNumber = try expectNumber ( ( error3 as! JSException ) . thrownValue )
785
785
try expectEqual ( errorNumber, 3.0 )
786
786
787
787
// MARK: Simple function calls
788
788
let error4 = try expectThrow ( try prop_9. func1. function!. throws ( ) )
789
- try expectEqual ( error4 is JSValue , true )
790
- let errorObject2 = JSError ( from: error4 as! JSValue )
789
+ try expectEqual ( error4 is JSException , true )
790
+ let errorObject2 = JSError ( from: ( error4 as! JSException ) . thrownValue )
791
791
try expectNotNil ( errorObject2)
792
792
793
793
// MARK: Throwing constructor call
794
794
let Animal = JSObject . global. Animal. function!
795
795
_ = try Animal . throws. new ( " Tama " , 3 , true )
796
796
let ageError = try expectThrow ( try Animal . throws. new ( " Tama " , - 3 , true ) )
797
- try expectEqual ( ageError is JSValue , true )
798
- let errorObject3 = JSError ( from: ageError as! JSValue )
797
+ try expectEqual ( ageError is JSException , true )
798
+ let errorObject3 = JSError ( from: ( ageError as! JSException ) . thrownValue )
799
799
try expectNotNil ( errorObject3)
800
800
}
801
801
@@ -824,18 +824,15 @@ try test("Unhandled Exception") {
824
824
825
825
// MARK: Throwing method calls
826
826
let error1 = try wrapUnsafeThrowableFunction { _ = prop_9. object!. func1!( ) }
827
- try expectEqual ( error1 is JSValue , true )
828
- let errorObject = JSError ( from: error1 as! JSValue )
827
+ let errorObject = JSError ( from: error1)
829
828
try expectNotNil ( errorObject)
830
829
831
830
let error2 = try wrapUnsafeThrowableFunction { _ = prop_9. object!. func2!( ) }
832
- try expectEqual ( error2 is JSValue , true )
833
- let errorString = try expectString ( error2 as! JSValue )
831
+ let errorString = try expectString ( error2)
834
832
try expectEqual ( errorString, " String Error " )
835
833
836
834
let error3 = try wrapUnsafeThrowableFunction { _ = prop_9. object!. func3!( ) }
837
- try expectEqual ( error3 is JSValue , true )
838
- let errorNumber = try expectNumber ( error3 as! JSValue )
835
+ let errorNumber = try expectNumber ( error3)
839
836
try expectEqual ( errorNumber, 3.0 )
840
837
}
841
838
0 commit comments