Skip to content

Add missing error handling for requests #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 120 additions & 24 deletions agilecrm/agilecrm.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ ContactAPI.prototype.add = function add(contact, success, failure) {
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(contact);
Expand Down Expand Up @@ -219,7 +223,11 @@ ContactAPI.prototype.update = function update(contact, success, failure) {
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(contact);
Expand Down Expand Up @@ -258,7 +266,11 @@ ContactAPI.prototype.deleteContact = function deleteContact(contactId, success,
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
del.end();
Expand Down Expand Up @@ -295,7 +307,11 @@ ContactAPI.prototype.updateTagsById = function update(contact, success, failure)
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(contact);
Expand Down Expand Up @@ -334,7 +350,11 @@ ContactAPI.prototype.deleteTagsById = function update(contact, success, failure)
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(contact);
Expand Down Expand Up @@ -373,7 +393,11 @@ ContactAPI.prototype.createDeal = function createDeal(opportunity, success, fail
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(opportunity);
Expand Down Expand Up @@ -412,7 +436,11 @@ ContactAPI.prototype.updateDeal = function updateDeal(opportunity, success, fail
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(opportunity);
Expand Down Expand Up @@ -523,7 +551,11 @@ ContactAPI.prototype.deleteDealById = function deleteDealById(dealId, success, f
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
del.end();
Expand Down Expand Up @@ -560,7 +592,11 @@ ContactAPI.prototype.createNote = function createNote(note, success, failure) {
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(note);
Expand Down Expand Up @@ -599,7 +635,11 @@ ContactAPI.prototype.updateNote = function updateNote(note, success, failure) {
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(note);
Expand Down Expand Up @@ -673,7 +713,11 @@ ContactAPI.prototype.deleteNoteById = function deleteNoteById(contactId,noteId,
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
del.end();
Expand Down Expand Up @@ -710,7 +754,11 @@ ContactAPI.prototype.createTask = function createTask(task, success, failure) {
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(task);
Expand Down Expand Up @@ -748,7 +796,11 @@ ContactAPI.prototype.createTaskByEmail = function createTaskByEmail(email,task,
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(task);
Expand Down Expand Up @@ -786,7 +838,11 @@ ContactAPI.prototype.updateTask = function updateTask(task, success, failure) {
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(task);
Expand Down Expand Up @@ -859,7 +915,11 @@ ContactAPI.prototype.deleteTaskById = function deleteTaskById(taskId, success, f
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
del.end();
Expand Down Expand Up @@ -908,7 +968,11 @@ ContactAPI.prototype.changeContactOwner = function update(email, contactId, succ
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
put.write(post_data);
Expand Down Expand Up @@ -990,7 +1054,11 @@ ContactAPI.prototype.getContactsByPropertyFilter = function getContactsByPropert
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
put.write(post_data);
Expand Down Expand Up @@ -1038,7 +1106,11 @@ ContactAPI.prototype.getContactsByTagFilter = function getContactsByTagFilter(va
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
put.write(post_data);
Expand Down Expand Up @@ -1113,7 +1185,11 @@ ContactAPI.prototype.createCustomField = function createCustomField(customJson,
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(customJson);
Expand Down Expand Up @@ -1156,7 +1232,11 @@ ContactAPI.prototype.updateCustomField = function updateCustomField(customJson,
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(customJson);
Expand Down Expand Up @@ -1199,7 +1279,11 @@ ContactAPI.prototype.createEvent = function createEvent(customJson, success, fai
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
var data = JSON.stringify(customJson);
Expand Down Expand Up @@ -1249,7 +1333,11 @@ ContactAPI.prototype.addTagstoContacts = function addTagstoContacts(tags,contact
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
put.write(post_data);
Expand Down Expand Up @@ -1298,7 +1386,11 @@ ContactAPI.prototype.deleteTagstoContacts = function deleteTagstoContacts(tags,c
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
put.write(post_data);
Expand Down Expand Up @@ -1348,7 +1440,11 @@ ContactAPI.prototype.getCompaniesByPropertyFilter = function getCompaniesByPrope
failure(e);
}
});
});
}).on("error", function(e){
if (failure) {
failure(e);
}
});

try {
put.write(post_data);
Expand Down