@@ -8,8 +8,8 @@ use crate::{
88} ;
99
1010impl Interpreter {
11- /// Throws a `RangeError` with the specified message.
12- pub fn throw_range_error < M > ( & mut self , message : M ) -> ResultValue
11+ /// Constructs a `RangeError` with the specified message.
12+ pub fn construct_range_error < M > ( & mut self , message : M ) -> Value
1313 where
1414 M : Into < String > ,
1515 {
@@ -19,10 +19,19 @@ impl Interpreter {
1919 vec ! [ Const :: from( message. into( ) ) . into( ) ] ,
2020 ) )
2121 . run ( self )
22+ . expect_err ( "RangeError should always throw" )
2223 }
2324
24- /// Throws a `TypeError` with the specified message.
25- pub fn throw_type_error < M > ( & mut self , message : M ) -> ResultValue
25+ /// Throws a `RangeError` with the specified message.
26+ pub fn throw_range_error < M > ( & mut self , message : M ) -> ResultValue
27+ where
28+ M : Into < String > ,
29+ {
30+ Err ( self . construct_range_error ( message) )
31+ }
32+
33+ /// Constructs a `TypeError` with the specified message.
34+ pub fn construct_type_error < M > ( & mut self , message : M ) -> Value
2635 where
2736 M : Into < String > ,
2837 {
@@ -32,5 +41,30 @@ impl Interpreter {
3241 vec ! [ Const :: from( message. into( ) ) . into( ) ] ,
3342 ) )
3443 . run ( self )
44+ . expect_err ( "TypeError should always throw" )
45+ }
46+
47+ /// Throws a `TypeError` with the specified message.
48+ pub fn throw_type_error < M > ( & mut self , message : M ) -> ResultValue
49+ where
50+ M : Into < String > ,
51+ {
52+ Err ( self . construct_type_error ( message) )
53+ }
54+
55+ /// Constructs a `ReferenceError` with the specified message.
56+ pub fn construct_reference_error < M > ( & mut self , _message : M ) -> Value
57+ where
58+ M : Into < String > ,
59+ {
60+ unimplemented ! ( "ReferenceError: is not implemented" ) ;
61+ }
62+
63+ /// Throws a `ReferenceError` with the specified message.
64+ pub fn throw_reference_error < M > ( & mut self , message : M ) -> ResultValue
65+ where
66+ M : Into < String > ,
67+ {
68+ Err ( self . construct_reference_error ( message) )
3569 }
3670}
0 commit comments