question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when calling logError callback on error

See original GitHub issue

This is a simple task to compile sass to css with sourcemaps:

gulp.task('sass', function () {
    gulp.src(['*.scss'])
        .pipe(sourcemaps.init())
        .pipe(sass().on('error', sass.logError))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('dist'));
});

I’m getting this error if there is a syntax error on sass file:

/Users/lm/Sites/app/node_modules/gulp-sass/index.js:170
  this.emit('end');
       ^
TypeError: undefined is not a function
    at Function.logError (/Users/lm/Sites/app/node_modules/gulp-sass/index.js:170:8)
    at DestroyableTransform.<anonymous> (/Users/lm/Sites/app/gulpfile.js:109:16)
    at DestroyableTransform.emit (events.js:129:20)
    at onwriteError (/Users/lm/Sites/app/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:345:10)
    at onwrite (/Users/lm/Sites/app/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:363:5)
    at WritableState.onwrite (/Users/lm/Sites/app/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:123:5)
    at afterTransform (/Users/lm/Sites/app/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:84:5)
    at TransformState.afterTransform (/Users/lm/Sites/app/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:59:12)
    at errorM (/Users/lm/Sites/app/node_modules/gulp-sass/index.js:123:14)
    at Object.callback (/Users/lm/Sites/app/node_modules/gulp-sass/index.js:134:18)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

11reactions
alalondecommented, Aug 26, 2016

I wanted to write a ‘beep’ to the console by creating my own error callback. The trick is to manually bind the logError function:

.pipe(sass({...})
.on('error', function(err) {
  console.error('\x07'); // so it doesn't just fail (literally) silently!
  sass.logError.bind(this)(err);
}))

The syntax is a bit ridiculous, but it works!

0reactions
xzyfercommented, Mar 11, 2018

Closing as stale. There appear to be work arounds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Handle Errors in Asynchronous Javascript Code ...
The first argument of the callback is usually named error, whereby if something goes wrong in the asynchronous function, then the callback gets...
Read more >
Cannot verify calls to ILogger in .NET Core 3.0 Preview 8 ...
In .NET Core 2.2, I am able to use Moq to test calls made to an ILogger. ... I'm trying to setup a...
Read more >
Error handling with promises - The Modern JavaScript Tutorial
Promise chains are great at error handling. When a promise rejects, the control jumps to the closest rejection handler.
Read more >
Catching Errors thrown by callback functions - Stack Overflow
This first function works well by throwing the error. I am trying to get the second function to do the same. async facebook(req,...
Read more >
Handle errors in ASP.NET Core Blazor apps - Microsoft Learn
Discover how ASP.NET Core Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found