From 13c310a2c37e7fb09632f8ce13fe4b8817a75215 Mon Sep 17 00:00:00 2001 From: Richard Gubby Date: Wed, 17 Feb 2016 15:54:17 +0000 Subject: [PATCH] Updated to propagate errors --- citeproc-wrapper.js | 8 +++++--- test/test.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/citeproc-wrapper.js b/citeproc-wrapper.js index 76f2d94..435b2d8 100644 --- a/citeproc-wrapper.js +++ b/citeproc-wrapper.js @@ -7,11 +7,13 @@ function Citeproc (citations, styleLocation, localeLocation, done) { this.construct = function () { var self = this; - self.loadStyle(styleLocation, function () { - self.loadLocale(localeLocation, function () { + self.loadStyle(styleLocation, function (err) { + if (err) return done(err); + self.loadLocale(localeLocation, function (err) { + if (err) return done(err); self.setupSys(); citeproc = new CSL.Engine(sys, style); - done(citeproc); + done(null, citeproc); }); }); } diff --git a/test/test.js b/test/test.js index 3b63adb..70942bb 100644 --- a/test/test.js +++ b/test/test.js @@ -10,11 +10,11 @@ describe('citeproc-js', function () { var style = './styles/chicago-fullnote-bibliography.csl'; var locale = './locales/locales-nb-NO.xml'; - var cite = new Citeproc(citations, style, locale, function (citeproc) { + var cite = new Citeproc(citations, style, locale, function (err, citeproc) { citeproc.updateItems(Object.keys(citations)); var bibliography = citeproc.makeBibliography(); console.log(bibliography); - done(); + done(err); }); }); });