MCPcopy
hub / github.com/postcss/postcss / handleError

Method handleError

lib/lazy-result.js:209–246  ·  view source on GitHub ↗
(error, node)

Source from the content-addressed store, hash-verified

207 }
208
209 handleError(error, node) {
210 let plugin = this.result.lastPlugin
211 try {
212 if (node) node.addToError(error)
213 this.error = error
214 if (error.name === 'CssSyntaxError' && !error.plugin) {
215 error.plugin = plugin.postcssPlugin
216 error.setMessage()
217 } else if (plugin.postcssVersion) {
218 if (process.env.NODE_ENV !== 'production') {
219 let pluginName = plugin.postcssPlugin
220 let pluginVer = plugin.postcssVersion
221 let runtimeVer = this.result.processor.version
222 let a = pluginVer.split('.')
223 let b = runtimeVer.split('.')
224
225 if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
226 // eslint-disable-next-line no-console
227 console.error(
228 'Unknown error from PostCSS plugin. Your current PostCSS ' +
229 'version is ' +
230 runtimeVer +
231 ', but ' +
232 pluginName +
233 ' uses ' +
234 pluginVer +
235 '. Perhaps this is the source of the error below.'
236 )
237 }
238 }
239 }
240 } catch (err) {
241 /* c8 ignore next 3 */
242 // eslint-disable-next-line no-console
243 if (console && console.error) console.error(err)
244 }
245 return error
246 }
247
248 prepareVisitors() {
249 this.listeners = {}

Callers 4

runAsyncMethod · 0.95
runOnRootMethod · 0.95
visitSyncMethod · 0.95
visitTickMethod · 0.95

Calls 3

addToErrorMethod · 0.80
setMessageMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected