Skip to content

Commit

Permalink
Merge pull request #722 from aholachek/orcid-api-fail
Browse files Browse the repository at this point in the history
show feedback to user instead of raising an error
  • Loading branch information
aholachek committed Dec 29, 2015
2 parents 9c8bb26 + b1eaa3c commit 4f3484e
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/js/modules/orcid/orcid_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,27 @@ define([
},

checkAccess: function() {
if (!this.hasAccess())
throw new Error('You must first obtain access_token before calling this API');
if (!this.config.apiEndpoint)
throw new Error('OrcidApi was not properly configured; apiEndpoint is missing');
},

var pubsub = this.getPubSub();
if (!this.hasAccess()){
pubsub.publish(pubsub.ALERT, new ApiFeedback({
code: ApiFeedback.CODES.ALERT,
msg: " No access_token found",
type: "danger",
title: "Unable to contact ORCID API",
modal : true
}));
}
if (!this.config.apiEndpoint){
pubsub.publish(pubsub.ALERT, new ApiFeedback({
code: ApiFeedback.CODES.ALERT,
msg: "The config variable apiEndpoint is missing",
type: "danger",
title: "Unable to contact ORCID API",
modal : true
}));
}
},

/**
* ===============================================================================
Expand Down

0 comments on commit 4f3484e

Please sign in to comment.