Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Show LESS errors in console, more thoroughly #9557

Merged
merged 1 commit into from
Dec 5, 2014

Conversation

peterflynn
Copy link
Member

Refinement of PR #8736: also log LESS errors from the parsing stage to the console (not just the output stage). Also covers cases where the file doesn't exist, for both CSS & LESS.

result.fail(function (error) {
console.error("[Extension] Unable to load stylesheet " + path, error);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more helpful to split this across the 2 fail handlers so user would get separate messages for "error loading file" and "error parsing LESS file".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@redmunds The different error cases are already distinguishable because the error objects is included in the log message -- though the message isn't super clear in the case of a loadFile() failure due to the way $.get() passes error objects back.

We'd actually need 3 different fail handlers to cover all the cases, if we split the handler, since there are 3 different places where reject() could be called. How about just detecting the two types of error results in a single handler, like this:

        result.fail(function (error, textStatus, httpError) {
            if (error.readyState !== undefined) {
                // If first arg is a jQXHR object, the real error info is in the next two args
                console.error("[Extension] Unable to read stylesheet " + path + ":", textStatus, httpError);
            } else {
                console.error("[Extension] Unable to process stylesheet " + path, error);
            }
        });

That improves the clarity of the message shown for loading errors, yet still guarantees we'll always log something in every failure case that could arise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that works for me.

@redmunds redmunds self-assigned this Nov 12, 2014
@redmunds
Copy link
Contributor

@peterflynn Done with review

…o the

console (not just the output stage). Also covers cases where the file
doesn't exist, for both CSS & LESS.
@peterflynn peterflynn force-pushed the pflynn/better-less-errors branch from ceea406 to c625d02 Compare December 5, 2014 01:33
@peterflynn
Copy link
Member Author

@redmunds Cool, thanks -- changes pushed. (I squashed so it's still a single commit).

@redmunds
Copy link
Contributor

redmunds commented Dec 5, 2014

Merging.

redmunds added a commit that referenced this pull request Dec 5, 2014
Show LESS errors in console, more thoroughly
@redmunds redmunds merged commit 04efd92 into master Dec 5, 2014
@redmunds redmunds deleted the pflynn/better-less-errors branch December 5, 2014 17:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants