cujojs / curl

curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.
https://github.com/cujojs/curl/wiki
Other
1.89k stars 216 forks source link

Callback required for error reporting in 0.7 #141

Closed asilvas closed 11 years ago

asilvas commented 11 years ago

Assuming there is something wrong, anything that would result in a "curl" call failing, if no success callback is provided, it will fail silently. Can make debugging difficult, as it is not uncommon to load some modules without the need for a callback.

In other words, assuming "mod1.js" does not exist, the following code will fail silently (no console log):


curl("mod1");

However, this will log an exception to the console log (since an error callback is not provided), which makes a lot of sense:


curl("mod1", function() { // success wont get called, of course, but an error will be thrown which is OK
});

And as you'd expect, if an error callback is provided, it will be invoked:


curl("mod1", function() { // success wont get calledOK
}, function(err) { // error will be provided
});

Minor, but would be nice if example 1 behaved like example 2, as in both cases an error callback is not provided, but we should know what went wrong.

unscriptable commented 11 years ago

good catch @asilvas. seems like it's minor, but i'll take a look at it.

unscriptable commented 11 years ago

related to #144

unscriptable commented 11 years ago

Can't currently see a way to achieve what you're asking without breaking this:

curl(["pkg/modA"]).then(success, failure);

However, this is now working in dev branch:

curl(["pkg/modA"], null, function (error) { });

-- John

asilvas commented 11 years ago

Makes sense, I cannot think of a good way around that one. An unfortunate issue, but not a big deal.