exceptions
This commit is contained in:
11
w10-exceptions/exceptions-node/index.js
Normal file
11
w10-exceptions/exceptions-node/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// read the file and print the content
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const data = fs.readFileSync(path.join(__dirname, 'data.json'), 'utf8');
|
||||
console.log(data);
|
||||
|
||||
// Fix this
|
||||
// Read a file that does not exist. This will throw an error.
|
||||
const wrong = fs.readFileSync(path.join(__dirname, 'wrong.json'), 'utf8');
|
||||
console.log(wrong);
|
||||
Reference in New Issue
Block a user