Skip to content
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
18 changes: 15 additions & 3 deletions es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ define([
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
callback(xhr.responseText);
if (xhr.status === 200) {
callback(null, xhr.responseText);
} else {
callback(new Error(xhr.statusText));
}
}
};
xhr.send(null);
Expand All @@ -31,7 +35,11 @@ define([
//Using special require.nodeRequire, something added by r.js.
var fs = require.nodeRequire('fs');
fetchText = function (path, callback) {
callback(fs.readFileSync(path, 'utf8'));
try {
callback(null, fs.readFileSync(path, 'utf8'));
} catch (error) {
callback(error);
}
};
}

Expand Down Expand Up @@ -80,7 +88,11 @@ return {
options.sourceFileName = sourceFileName;
options.sourceMap = config.isBuild ? false : 'inline';

fetchText(url, function (text) {
fetchText(url, function (error, text) {
if (error) {
return onload.error(error);
}

var code;
try {
code = babel.transform(text, options).code;
Expand Down