PluginError toString output
Imported from https://github.com/gulpjs/gulp-util/issues/74.
Currently console.log'ing the error outputs way too much:
{ [Error: error main.scss (Line 7: Invalid CSS after "@import ": expected file to import (string or url()), was "blah;")] message: 'error main.scss (Line 7: Invalid CSS after "@import ": expected file to import (string or url()), was "blah;")', showStack: false, showProperties: true, plugin: 'gulp-ruby-sass', __safety: { toString: [Function] } }It should only output:
[Error: error main.scss (Line 7: Invalid CSS after "@import ": expected file to import (string or url()), was "blah;")]Or even better:
[gulp-ruby-sass error: error main.scss (Line 7: Invalid CSS after "@import ": expected file to import (string or url()), was "blah;")]Just define a
.toStringmethod for it outputting what we want.re https://github.com/yeoman/generator-gulp-webapp/pull/242#issuecomment-67011031
/cc @sindresorhus @contra
Just noting that console.log does not use toString to format its output, e.g.
console.log({ foo: 'bar', toString: () => 'nice text' });
outputs
{ foo: 'bar', toString: () => 'nice text' }
If the goal is to change the output of console.log, as the ticket description implies, one has to use util.inspect.custom:
const util = require('util');
console.log({ foo: 'bar', [util.inspect.custom]: () => 'nice text' });
outputs:
nice text
Regardless, it would be nice to remove some unnecessary information from the output of toString, like domainEmitter [object Object].
@fasttime We already made attempts to improve this in https://github.com/gulpjs/plugin-error/commit/932946a72ed8911aaa362ce09ef9d14931a97542 - if we missed a property, I'm happy to add it to the list of exclusions and release as a bug fix. Want to PR?
@phated Okay, I made a PR: #26.