From 36aa5935b197dab8c2c7b3aee71897ecf89e0abb Mon Sep 17 00:00:00 2001 From: jim1_lin Date: Wed, 2 Mar 2016 16:50:00 +0800 Subject: [PATCH] change error msg --- spec/ParseObject.spec.js | 6 +----- src/Schema.js | 11 +++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/spec/ParseObject.spec.js b/spec/ParseObject.spec.js index ccd8920c..21920ae6 100644 --- a/spec/ParseObject.spec.js +++ b/spec/ParseObject.spec.js @@ -350,11 +350,7 @@ describe('Parse.Object testing', () => { var next = function(index) { if (index < tests.length) { tests[index].save().then(fail, error => { - if (types[index] === 'Pointer') { - expect(error.code).toEqual(Parse.Error.INVALID_POINTER); - } else { - expect(error.code).toEqual(Parse.Error.INCORRECT_TYPE); - } + expect(error.code).toEqual(Parse.Error.INCORRECT_TYPE); next(index + 1); }); } else { diff --git a/src/Schema.js b/src/Schema.js index 46bb9151..612e68e2 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -737,34 +737,33 @@ function getObjectType(obj) { if(obj.className) { return '*' + obj.className; } else { - throw new Parse.Error(Parse.Error.INVALID_POINTER, JSON.stringify(obj) + " is not a valid Pointer"); + throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type); } break; case 'File' : if(obj.name) { return 'file'; } else { - let msg = obj.name? JSON.stringify(obj) + " is not a valid File" : "File has no name"; - throw new Parse.Error(Parse.Error.INCORRECT_TYPE, msg); + throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type); } break; case 'Date' : if(obj.iso) { return 'date'; } else { - throw new Parse.Error(Parse.Error.INCORRECT_TYPE, JSON.stringify(obj) + " is not a valid Date"); + throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type); } break; case 'GeoPoint' : if(obj.latitude != null && obj.longitude != null) { return 'geopoint'; } else { - throw new Parse.Error(Parse.Error.INCORRECT_TYPE, JSON.stringify(obj) + " is not a valid GeoPoint"); + throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type); } break; case 'Bytes' : if(!obj.base64) { - throw new Parse.Error(Parse.Error.INCORRECT_TYPE, 'Bytes type has no base64 field: ' + JSON.stringify(obj)); + throw new Parse.Error(Parse.Error.INCORRECT_TYPE, "This is not a valid "+obj.__type); } break; default :