{"action":"created","issue":{"url":"https://api.github.com/repos/postcss/postcss/issues/177","labels_url":"https://api.github.com/repos/postcss/postcss/issues/177/labels{/name}","comments_url":"https://api.github.com/repos/postcss/postcss/issues/177/comments","events_url":"https://api.github.com/repos/postcss/postcss/issues/177/events","html_url":"https://github.com/postcss/postcss/issues/177","id":56721207,"number":177,"title":"new API for plugin errors/warnings","user":{"login":"MoOx","id":157534,"avatar_url":"https://avatars.githubusercontent.com/u/157534?v=3","gravatar_id":"","url":"https://api.github.com/users/MoOx","html_url":"https://github.com/MoOx","followers_url":"https://api.github.com/users/MoOx/followers","following_url":"https://api.github.com/users/MoOx/following{/other_user}","gists_url":"https://api.github.com/users/MoOx/gists{/gist_id}","starred_url":"https://api.github.com/users/MoOx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MoOx/subscriptions","organizations_url":"https://api.github.com/users/MoOx/orgs","repos_url":"https://api.github.com/users/MoOx/repos","events_url":"https://api.github.com/users/MoOx/events{/privacy}","received_events_url":"https://api.github.com/users/MoOx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/postcss/postcss/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-02-05T20:01:03Z","updated_at":"2015-02-06T09:07:56Z","closed_at":null,"body":"Currently postcss can encounter unrecoverable error during parsing, that might throw exceptions.\r\nNext level should be to add a new feature to allow plugins to report error/warnings in a stack.\r\nA plugin might return an error during the `process()` if the current css is not fitting the requirements (like  custom-prop need a --stuff defined before using var(--stuff).\r\nWe can also imagine warnings if a plugin want to warn the user about something it's recommanded to do ([see stylelint](http://stylelint.github.io/)).\r\n\r\nWe can even imagine that plugins will be able to check postcss version & with the same api solve #163.\r\n\r\n```js\r\nvar p = require(\"postcss\")\r\nvar result = p().use(/*...*/).process()\r\nresult.css // already existing\r\nresult.errors // [ ... ]\r\nresult.warnings // [ ... ]\r\n```\r\n\r\nThe format should contain at least source (filename, l, c) & message + plugin ref.\r\n\r\nWe might also reuse `node.error()` and a new `node.warning()`.\r\n\r\nThat would helps a lot for stylelint and https://github.com/cssnext/cssnext/issues/64 as it might help a lot to make webpack loader more awesome (with real reportings, not just stupid console.log)"},"comment":{"url":"https://api.github.com/repos/postcss/postcss/issues/comments/73206954","html_url":"https://github.com/postcss/postcss/issues/177#issuecomment-73206954","issue_url":"https://api.github.com/repos/postcss/postcss/issues/177","id":73206954,"user":{"login":"MoOx","id":157534,"avatar_url":"https://avatars.githubusercontent.com/u/157534?v=3","gravatar_id":"","url":"https://api.github.com/users/MoOx","html_url":"https://github.com/MoOx","followers_url":"https://api.github.com/users/MoOx/followers","following_url":"https://api.github.com/users/MoOx/following{/other_user}","gists_url":"https://api.github.com/users/MoOx/gists{/gist_id}","starred_url":"https://api.github.com/users/MoOx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MoOx/subscriptions","organizations_url":"https://api.github.com/users/MoOx/orgs","repos_url":"https://api.github.com/users/MoOx/repos","events_url":"https://api.github.com/users/MoOx/events{/privacy}","received_events_url":"https://api.github.com/users/MoOx/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T09:07:56Z","updated_at":"2015-02-06T09:07:56Z","body":"It's up to the plugin to decide if they want to throw or just notify. Plugins can already throw exceptions.\r\nI think we should focus on a way to provide a mecanism so plugins can communicate with users.\r\n\r\nWe should not care plugin will use error, warnings, simple logs... We should just provide a generic way to returns message with a given type (severity can be PostCSSMessage.ERROR, PostCSSMessage.WARN, PostCSSMessage.LOG or other I don't see yet).\r\nThat's why I think `result.messages` seems more relevant than `results.warnings` or `.errors`."}}