GeezerVison is showing github.com — changes :arrow_right_hook: · maninder123/fullstack-javascript@a63ceae
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: 15-board-web/web.js +10-7Lines changed: 10 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,13 +62,16 @@ client.connect(uri, function(error, db) { |
62 | 62 | if (uri == '' || uri == '/') uri = 'index.html' |
63 | 63 | filename = path.join(__dirname, staticFolder, uri) |
64 | 64 | console.log('Processing file: ', filename) |
65 | | - stats = fs.statSync(filename) |
66 | | - if (error) { |
67 | | - console.error(error) |
68 | | - response.writeHead(404, { |
69 | | - 'Content-Type': 'text/plain'}) |
70 | | - response.write('404 Not Found\n') |
71 | | - return response.end() |
| 65 | + try { |
| 66 | + stats = fs.statSync(filename) |
| 67 | + } catch (error) { |
| 68 | + if (error) { |
| 69 | + console.error(error) |
| 70 | + response.writeHead(404, { |
| 71 | + 'Content-Type': 'text/plain'}) |
| 72 | + response.write('404 Not Found\n') |
| 73 | + return response.end() |
| 74 | + } |
72 | 75 | } |
73 | 76 | if(!stats.isFile()) { |
74 | 77 | response.writeHead(404, { |
|