Skip to content

Commit

Permalink
s/fail/catch/g
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbanham committed Mar 8, 2017
1 parent 5d31493 commit 308b85d
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 78 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Print a count of invoices:
xeroClient.core.invoices.getInvoices()
.then(function(invoices) {
console.log("Invoices: " + invoices.length);
}).fail(function(err) {
}).catch(function(err) {
console.error(err);
});
```
Expand All @@ -151,7 +151,7 @@ xeroClient.core.contacts.getContacts({
contacts.forEach(function(contact) {
console.log(contact.Name);
});
}).fail(function(err) {
}).catch(function(err) {
console.error(err);
});
```
Expand All @@ -160,7 +160,7 @@ Efficient paging:

```javascript
xeroClient.core.contacts.getContacts({ pager: {start:1 /* page number */, callback: onContacts}})
.fail(function(err) {
.catch(function(err) {
console.log('Oh no, an error');
});

Expand Down
10 changes: 5 additions & 5 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ _.extend(Application.prototype, {
}

})
.fail(function(err) {
.catch(function(err) {
logger.error(err);
throw err;
})
Expand Down Expand Up @@ -198,7 +198,7 @@ _.extend(Application.prototype, {
deferred.resolve(ret);
callback && callback(null, obj, res);
})
.fail(function(err) {
.catch(function(err) {
logger.error(err);
throw err;
})
Expand Down Expand Up @@ -300,7 +300,7 @@ _.extend(Application.prototype, {
callback && callback(null, obj, res);
}
})
.fail(function(err) {
.catch(function(err) {
logger.error(err);
throw err;
})
Expand Down Expand Up @@ -367,7 +367,7 @@ _.extend(Application.prototype, {
if (ret && ret.response)
return ret.response;
})
.fail(function(err) {
.catch(function(err) {
logger.error(err);
throw err;
})
Expand All @@ -390,7 +390,7 @@ _.extend(Application.prototype, {
if (ret && ret.response)
return self.convertEntities(ret.response, clonedOptions);
})
.fail(function(err) {
.catch(function(err) {
logger.error(err);
throw err;
})
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var Attachment = Entity.extend(AttachmentSchema, {
console.log(ret);
return ret.response.Attachments.Attachment;
})
.fail(function(err) {
.catch(function(err) {
console.log(err);
})

Expand Down
2 changes: 1 addition & 1 deletion lib/entity_helpers/journals.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var Journals = EntityHelper.extend({
callback && callback(null, journals);
return journals;
})
.fail(function(err) {
.catch(function(err) {
callback && callback(err);
throw err;
})
Expand Down
2 changes: 1 addition & 1 deletion lib/entity_helpers/organisations.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var Organisations = EntityHelper.extend({
callback && callback(null, _.first(organisations));
return _.first(organisations);
})
.fail(function(err) {
.catch(function(err) {
callback && callback(err);
throw err;
})
Expand Down
8 changes: 4 additions & 4 deletions sample_app/sample_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ app.get('/employees', function(req, res) {
}
});
})
.fail(function(err) {
.catch(function(err) {
console.log(err)
res.render('employees', {
error: err,
Expand Down Expand Up @@ -306,7 +306,7 @@ app.get('/timesheets', function(req, res) {
}
});
})
.fail(function(err) {
.catch(function(err) {
console.log(err)
res.render('timesheets', {
error: err,
Expand Down Expand Up @@ -337,7 +337,7 @@ app.use('/createtimesheet', function(req, res) {
.then(function(ret) {
res.render('createtimesheet', { timesheets: ret.entities })
})
.fail(function(err) {
.catch(function(err) {
res.render('createtimesheet', { err: err })
})

Expand Down Expand Up @@ -400,7 +400,7 @@ app.use('/createinvoice', function(req, res) {
.then(function(ret) {
res.render('createinvoice', { outcome: 'Invoice created', id: ret.entities[0].InvoiceID })
})
.fail(function(err) {
.catch(function(err) {
res.render('createinvoice', { outcome: 'Error', err: err })
})

Expand Down
6 changes: 3 additions & 3 deletions sample_app/views/index.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ privateApp.core.invoices.getInvoices()
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">invoices</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Invoices: "</span> + invoices.length);

}).fail(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
}).catch(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
<span class="hljs-built_in">console</span>.error(err);
});
</code></pre>
Expand All @@ -126,13 +126,13 @@ privateApp.core.contacts.getContacts({
contacts.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">contact</span>) </span>{
<span class="hljs-built_in">console</span>.log(contact.Name);
});
}).fail(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
}).catch(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
<span class="hljs-built_in">console</span>.error(err);
});
</code></pre>
<p>Efficient paging:</p>
<pre><code class="language-javascript">privateApp.core.contacts.getContacts({ pager: {start:<span class="hljs-number">1</span> <span class="hljs-comment">/* page number */</span>, callback:onContacts}})
.fail(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
.catch(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Oh no, an error'</span>);
});

Expand Down
Loading

0 comments on commit 308b85d

Please sign in to comment.