Answer the question
In order to leave comments, you need to log in
How to convert existing js function to coffeescript?
Today I decided to try to work with coffeescript and a plug appeared, I don’t understand how to write this function on coffee?
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error('Port ' + port + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error('Port ' + port + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
Answer the question
In order to leave comments, you need to log in
onError = (error) ->
throw error if error.syscall isnt 'listen'
# handle specific listen errors with friendly messages
switch error.code
when 'EACCES'
console.error 'Port ' + port + ' requires elevated privileges'
process.exit 1
when 'EADDRINUSE'
console.error 'Port ' + port + ' is already in use'
process.exit 1
else
throw error
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question