solidusjs / solidus

A simple server that generates pages from JSON and Templates
MIT License
28 stars 7 forks source link

Custom exceptions aren’t caught when running preprocessors #127

Closed pushred closed 9 years ago

pushred commented 9 years ago

It seems that at least some exceptions aren’t caught when thrown in a preprocessor. Using the js-yaml module I noticed that exceptions regarding syntax errors stopped short:

[2015-02-13T02:50:15.838Z] 9 Preprocessor Error:
undefined

Catching the error on my own:

{ name: 'YAMLException',
  reason: 'can not read a block mapping entry; a multiline key may not be an implicit key',
  mark: 
   { name: null,
     buffer: '/:\n\n  ...\n\u0000',
     position: 390,
     line: 14,
     column: 12 },
  message: 'JS-YAML: can not read a block mapping entry; a multiline key may not be an implicit key at line 15, column 13:\n    /example:\n                ^' }

Running the same code in a process of my own rather than the preprocessor, the exception was thrown correctly. I suspect this has to do with worker-farm, see https://github.com/rvagg/node-worker-farm/issues/9. js-yaml throws it’s own YAMLException class but worker-farm only handles Errors.

Not sure what we can do about this beyond not using js-yaml in a worker process or somehow allowing worker-farm’s handling to be extended to support such cases.

joanniclaborde commented 9 years ago

The preprocessor errors never escape our worker, so it's probably just an issue with logging that kind of error. I'll tweak that line to try other fields when I have 2 minutes.