Skip to content

Commit 36aa593

Browse files
committed
change error msg
1 parent 430dd79 commit 36aa593

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

spec/ParseObject.spec.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,7 @@ describe('Parse.Object testing', () => {
350350
var next = function(index) {
351351
if (index < tests.length) {
352352
tests[index].save().then(fail, error => {
353-
if (types[index] === 'Pointer') {
354-
expect(error.code).toEqual(Parse.Error.INVALID_POINTER);
355-
} else {
356-
expect(error.code).toEqual(Parse.Error.INCORRECT_TYPE);
357-
}
353+
expect(error.code).toEqual(Parse.Error.INCORRECT_TYPE);
358354
next(index + 1);
359355
});
360356
} else {

src/Schema.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,34 +737,33 @@ function getObjectType(obj) {
737737
if(obj.className) {
738738
return '*' + obj.className;
739739
} else {
740-
throw new Parse.Error(Parse.Error.INVALID_POINTER, JSON.stringify(obj) + " is not a valid Pointer");
740+
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type);
741741
}
742742
break;
743743
case 'File' :
744744
if(obj.name) {
745745
return 'file';
746746
} else {
747-
let msg = obj.name? JSON.stringify(obj) + " is not a valid File" : "File has no name";
748-
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, msg);
747+
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type);
749748
}
750749
break;
751750
case 'Date' :
752751
if(obj.iso) {
753752
return 'date';
754753
} else {
755-
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, JSON.stringify(obj) + " is not a valid Date");
754+
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type);
756755
}
757756
break;
758757
case 'GeoPoint' :
759758
if(obj.latitude != null && obj.longitude != null) {
760759
return 'geopoint';
761760
} else {
762-
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, JSON.stringify(obj) + " is not a valid GeoPoint");
761+
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type);
763762
}
764763
break;
765764
case 'Bytes' :
766765
if(!obj.base64) {
767-
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, 'Bytes type has no base64 field: ' + JSON.stringify(obj));
766+
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type);
768767
}
769768
break;
770769
default :

0 commit comments

Comments
 (0)