exceptions
This commit is contained in:
4
w10-exceptions/exceptions-node/data.json
Normal file
4
w10-exceptions/exceptions-node/data.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Andrea",
|
||||
"job": "Professor"
|
||||
}
|
||||
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);
|
||||
9
w10-exceptions/exceptions-node/package.json
Normal file
9
w10-exceptions/exceptions-node/package.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "exceptions1",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": ""
|
||||
}
|
||||
Reference in New Issue
Block a user