@@ -152,7 +152,7 @@ exports.XMLHttpRequest = function() {
152152
153153 // Check for valid request method
154154 if ( ! isAllowedHttpMethod ( method ) ) {
155- throw "SecurityError: Request method not allowed" ;
155+ throw new Error ( "SecurityError: Request method not allowed" ) ;
156156 }
157157
158158 settings = {
@@ -184,14 +184,14 @@ exports.XMLHttpRequest = function() {
184184 */
185185 this . setRequestHeader = function ( header , value ) {
186186 if ( this . readyState != this . OPENED ) {
187- throw "INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN" ;
187+ throw new Error ( "INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN" ) ;
188188 }
189189 if ( ! isAllowedHttpHeader ( header ) ) {
190190 console . warn ( 'Refused to set unsafe header "' + header + '"' ) ;
191191 return ;
192192 }
193193 if ( sendFlag ) {
194- throw "INVALID_STATE_ERR: send flag is true" ;
194+ throw new Error ( "INVALID_STATE_ERR: send flag is true" ) ;
195195 }
196196 headers [ header ] = value ;
197197 } ;
@@ -258,11 +258,11 @@ exports.XMLHttpRequest = function() {
258258 */
259259 this . send = function ( data ) {
260260 if ( this . readyState != this . OPENED ) {
261- throw "INVALID_STATE_ERR: connection must be opened before send() is called" ;
261+ throw new Error ( "INVALID_STATE_ERR: connection must be opened before send() is called" ) ;
262262 }
263263
264264 if ( sendFlag ) {
265- throw "INVALID_STATE_ERR: send has already been called" ;
265+ throw new Error ( "INVALID_STATE_ERR: send has already been called" ) ;
266266 }
267267
268268 var ssl = false , local = false ;
@@ -287,13 +287,13 @@ exports.XMLHttpRequest = function() {
287287 break ;
288288
289289 default :
290- throw "Protocol not supported." ;
290+ throw new Error ( "Protocol not supported." ) ;
291291 }
292292
293293 // Load files off the local filesystem (file://)
294294 if ( local ) {
295295 if ( settings . method !== "GET" ) {
296- throw "XMLHttpRequest: Only GET method is supported" ;
296+ throw new Error ( "XMLHttpRequest: Only GET method is supported" ) ;
297297 }
298298
299299 if ( settings . async ) {
0 commit comments