borodean / postcss-assets

An asset manager for PostCSS
MIT License
537 stars 32 forks source link

Error handling #8

Closed ai closed 9 years ago

ai commented 9 years ago
  1. Why you print warning insetad of throw a error? Many build tools doesn’t show a warnings and it makes debug harder.
  2. PostCSS has special API to get source of node (even by previous source map):
if ( !isFound ) {
    throw decl.error('Asset not found or unreadable: ' + assetPath)
}
borodean commented 9 years ago

@ai, warning istead of throwing errors is based on the intent of making postcss-assets as unobtrusive as possible. Erroneous pieces of code are getting skipped, those which could be succesfully processed are being processed.

ai commented 9 years ago

But what developing process you suggest. I will wrote url(img.pnd), refreshed page and saw blank icon. Then I left 2 minutes to check my styles, then half minute to find a warning in big logs and only after ask that steps I saw, that I wrote pnd instead of png.

Real logs (for example from gulp or webpack) are to long to find warning, that broke me styles.

What user cases you suggest, when warning is better, that error?

ai commented 9 years ago

BTW, in postcss-simple-vars and postcss-mixins I have special silent option. With this option plugin will not throw error on unknown variable or mixin and will just left them in CSS.

ai commented 9 years ago

I found user cases for warning:

Both this examples is because we didn't add some social asset() function and used url(), so we didn't know what user wants - use file path here or just wrote relative URL.

borodean commented 9 years ago

@ai

I will wrote url(img.pnd), refreshed page and saw blank icon.

Then you would inspect the element which looks weird and see it has an unprocessed wrong URL set.

ai commented 9 years ago

Some of users may think, that plugin just didn't work, because they will miss warning in logs.

Also even if I know about warning, I need to spend time to understand the reason of problem. But plugin can save my time if it say what the problem.

Anyway there is no sense in width: width(path) in my CSS.