@@ -154,7 +154,7 @@ exports.XMLHttpRequest = function() {
154154
155155 // Check for valid request method
156156 if ( ! isAllowedHttpMethod ( method ) ) {
157- throw "SecurityError: Request method not allowed" ;
157+ throw new Error ( "SecurityError: Request method not allowed" ) ;
158158 }
159159
160160 settings = {
@@ -186,14 +186,14 @@ exports.XMLHttpRequest = function() {
186186 */
187187 this . setRequestHeader = function ( header , value ) {
188188 if ( this . readyState !== this . OPENED ) {
189- throw "INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN" ;
189+ throw new Error ( "INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN" ) ;
190190 }
191191 if ( ! isAllowedHttpHeader ( header ) ) {
192192 console . warn ( "Refused to set unsafe header \"" + header + "\"" ) ;
193193 return ;
194194 }
195195 if ( sendFlag ) {
196- throw "INVALID_STATE_ERR: send flag is true" ;
196+ throw new Error ( "INVALID_STATE_ERR: send flag is true" ) ;
197197 }
198198 headers [ header ] = value ;
199199 } ;
@@ -260,11 +260,11 @@ exports.XMLHttpRequest = function() {
260260 */
261261 this . send = function ( data ) {
262262 if ( this . readyState !== this . OPENED ) {
263- throw "INVALID_STATE_ERR: connection must be opened before send() is called" ;
263+ throw new Error ( "INVALID_STATE_ERR: connection must be opened before send() is called" ) ;
264264 }
265265
266266 if ( sendFlag ) {
267- throw "INVALID_STATE_ERR: send has already been called" ;
267+ throw new Error ( "INVALID_STATE_ERR: send has already been called" ) ;
268268 }
269269
270270 var ssl = false , local = false ;
@@ -290,13 +290,13 @@ exports.XMLHttpRequest = function() {
290290 break ;
291291
292292 default :
293- throw "Protocol not supported." ;
293+ throw new Error ( "Protocol not supported." ) ;
294294 }
295295
296296 // Load files off the local filesystem (file://)
297297 if ( local ) {
298298 if ( settings . method !== "GET" ) {
299- throw "XMLHttpRequest: Only GET method is supported" ;
299+ throw new Error ( "XMLHttpRequest: Only GET method is supported" ) ;
300300 }
301301
302302 if ( settings . async ) {
0 commit comments