@@ -178,7 +178,7 @@ module.exports = function(AV) {
178178 } else if ( previous instanceof AV . Op . Increment ) {
179179 return new AV . Op . Increment ( this . amount ( ) + previous . amount ( ) ) ;
180180 } else {
181- throw " Op is invalid after previous op." ;
181+ throw new Error ( ' Op is invalid after previous op.' ) ;
182182 }
183183 } ,
184184
@@ -231,7 +231,7 @@ module.exports = function(AV) {
231231 } else if ( previous instanceof AV . Op . Add ) {
232232 return new AV . Op . Add ( previous . objects ( ) . concat ( this . objects ( ) ) ) ;
233233 } else {
234- throw " Op is invalid after previous op." ;
234+ throw new Error ( ' Op is invalid after previous op.' ) ;
235235 }
236236 } ,
237237
@@ -288,7 +288,7 @@ module.exports = function(AV) {
288288 } else if ( previous instanceof AV . Op . AddUnique ) {
289289 return new AV . Op . AddUnique ( this . _estimate ( previous . objects ( ) ) ) ;
290290 } else {
291- throw " Op is invalid after previous op." ;
291+ throw new Error ( ' Op is invalid after previous op.' ) ;
292292 }
293293 } ,
294294
@@ -361,7 +361,7 @@ module.exports = function(AV) {
361361 } else if ( previous instanceof AV . Op . Remove ) {
362362 return new AV . Op . Remove ( _ . union ( previous . objects ( ) , this . objects ( ) ) ) ;
363363 } else {
364- throw " Op is invalid after previous op." ;
364+ throw new Error ( ' Op is invalid after previous op.' ) ;
365365 }
366366 } ,
367367
@@ -405,14 +405,14 @@ module.exports = function(AV) {
405405 var pointerToId = function ( object ) {
406406 if ( object instanceof AV . Object ) {
407407 if ( ! object . id ) {
408- throw " You can't add an unsaved AV.Object to a relation." ;
408+ throw new Error ( ' You can\ 't add an unsaved AV.Object to a relation.' ) ;
409409 }
410410 if ( ! self . _targetClassName ) {
411411 self . _targetClassName = object . className ;
412412 }
413413 if ( self . _targetClassName !== object . className ) {
414- throw "Tried to create a AV.Relation with 2 different types: " +
415- self . _targetClassName + " and " + object . className + "." ;
414+ throw new Error ( "Tried to create a AV.Relation with 2 different types: " +
415+ self . _targetClassName + " and " + object . className + "." ) ;
416416 }
417417 return object . id ;
418418 }
@@ -486,12 +486,12 @@ module.exports = function(AV) {
486486 if ( ! previous ) {
487487 return this ;
488488 } else if ( previous instanceof AV . Op . Unset ) {
489- throw " You can't modify a relation after deleting it." ;
489+ throw new Error ( ' You can\ 't modify a relation after deleting it.' ) ;
490490 } else if ( previous instanceof AV . Op . Relation ) {
491491 if ( previous . _targetClassName &&
492492 previous . _targetClassName !== this . _targetClassName ) {
493- throw "Related object must be of class " + previous . _targetClassName +
494- ", but " + this . _targetClassName + " was passed in." ;
493+ throw new Error ( "Related object must be of class " + previous . _targetClassName +
494+ ", but " + this . _targetClassName + " was passed in." ) ;
495495 }
496496 var newAdd = _ . union ( _ . difference ( previous . relationsToAdd ,
497497 this . relationsToRemove ) ,
@@ -504,7 +504,7 @@ module.exports = function(AV) {
504504 newRelation . _targetClassName = this . _targetClassName ;
505505 return newRelation ;
506506 } else {
507- throw " Op is invalid after previous op." ;
507+ throw new Error ( ' Op is invalid after previous op.' ) ;
508508 }
509509 } ,
510510
@@ -516,16 +516,16 @@ module.exports = function(AV) {
516516 if ( this . _targetClassName ) {
517517 if ( oldValue . targetClassName ) {
518518 if ( oldValue . targetClassName !== this . _targetClassName ) {
519- throw "Related object must be a " + oldValue . targetClassName +
520- ", but a " + this . _targetClassName + " was passed in." ;
519+ throw new Error ( "Related object must be a " + oldValue . targetClassName +
520+ ", but a " + this . _targetClassName + " was passed in." ) ;
521521 }
522522 } else {
523523 oldValue . targetClassName = this . _targetClassName ;
524524 }
525525 }
526526 return oldValue ;
527527 } else {
528- throw " Op is invalid after previous op." ;
528+ throw new Error ( ' Op is invalid after previous op.' ) ;
529529 }
530530 }
531531 } ) ;
0 commit comments