-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
An ENOENT error is thrown when logging the stack trace for an error that contains a file path that is no longer on disk or fails to be read from disk.
Using CoffeeScript 1.9.1
Steps To Reproduce
- Copy the code below to a file
- Run that file
Code
fs = require 'fs'
path = require 'path'
filePath = path.join(__dirname, 'file.coffee')
# Create a file that exports a function that throws an error
fs.writeFileSync(filePath, "module.exports = -> throw new Error()")
# Require the file
throwsAnError = require(filePath)
# Delete the file
fs.unlinkSync(filePath)
# Call the exported function that throws an error and print the stack trace
try
throwsAnError()
catch error
console.error(error.stack)Expected Output
Error
at module.exports (/Users/kevin/github/cs-test/file.coffee:1:31)
at Object.<anonymous> (/Users/kevin/github/cs-test/a.coffee:18:3)
at Object.<anonymous> (/Users/kevin/github/cs-test/a.coffee:1:1)
at Module._compile (module.js:456:26)
Actual Output
Error: ENOENT, no such file or directory '/Users/kevin/github/cs-test/file.coffee'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at Object.exports._compileFile (/Users/kevin/github/cs-test/node_modules/coffee-script/lib/coffee-script/coffee-script.js:221:14)
at getSourceMap (/Users/kevin/github/cs-test/node_modules/coffee-script/lib/coffee-script/coffee-script.js:340:22)
at getSourceMapping (/Users/kevin/github/cs-test/node_modules/coffee-script/lib/coffee-script/coffee-script.js:348:19)
at formatSourcePosition (/Users/kevin/github/cs-test/node_modules/coffee-script/lib/coffee-script/coffee-script.js:300:16)
at /Users/kevin/github/cs-test/node_modules/coffee-script/lib/coffee-script/coffee-script.js:366:33
at Function.Error.prepareStackTrace (/Users/kevin/github/cs-test/node_modules/coffee-script/lib/coffee-script/coffee-script.js:369:7)
at Object.<anonymous> (/Users/kevin/github/cs-test/a.coffee:20:22)
at Object.<anonymous> (/Users/kevin/github/cs-test/a.coffee:1:1)
at Module._compile (module.js:456:26)
Metadata
Metadata
Assignees
Labels
No labels