Skip to content

Commit f664d43

Browse files
committed
Fix orcid deletion
Removes the type check and makes it more lax. Also now rejects the promise instead of throwing, so that it gets properly handled inside the promise context. Throwing the error here does not get handled in jQuery deferreds unlike in the native Promises
1 parent 4c6f866 commit f664d43

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/js/modules/orcid/orcid_api.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,14 @@ define([
541541
/**
542542
* Delete a single work from ORCiD
543543
*
544-
* @param {Number} putCode - putcode of work to be deleted
544+
* @param {String | Number} putCode - putcode of work to be deleted
545545
* @returns {jQuery.Promise} - promise for the request
546546
*/
547547
deleteWork: function(putCode) {
548-
if (!_.isNumber(putCode)) {
549-
throw new TypeError('putcode should be a number');
548+
if (!putCode) {
549+
return $.Deferred()
550+
.reject('No Putcode found')
551+
.promise();
550552
}
551553
var $dd = $.Deferred();
552554
this.deleteCache.push({

0 commit comments

Comments
 (0)