-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.txt
More file actions
116 lines (99 loc) · 3.01 KB
/
Copy pathnotes.txt
File metadata and controls
116 lines (99 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// ================================================================
api json response format:
{ status: xx, result: xxx }
or
{ status: xx, error: { code: xxx, text: xxx } }
// ================================================================
async you nested functions:
async.waterfall([
function readFile(readFileCallback) {
fs.readFile('stocktest.json', readFileCallback);
},
function processFile(file, processFileCallback) {
var stocksJson = JSON.parse(file);
if (stocksJson[ticker] != null) {
stocksJson[ticker].price = value;
fs.writeFile('stocktest.json', JSON.stringify(stocksJson, null, 4), function (error) {
if (!err) {
console.log("File successfully written");
}
processFileCallback(err);
});
}
else {
console.log(ticker + " doesn't exist on the json");
processFileCallback(null);
}
}
], function (error) {
if (error) {
//handle readFile error or processFile error here
}
});
// ================================================================
Operational errors vs. programmer errors
It's helpful to divide all errors into two broad categories:
Operational errors represent run-time problems experienced by correctly-written programs.
These are not bugs in the program. In fact, these are usually problems with something else:
the system itself (e.g., out of memory or too many open files),
the system's configuration (e.g., no route to a remote host),
the network (e.g., socket hang-up), or a remote service (e.g., a 500 error, failure to connect, or the like).
Examples include:
failed to connect to server
failed to resolve hostname
invalid user input
request timeout
server returned a 500 response
socket hang-up
system is out of memory
Programmer errors are bugs in the program.
These are things that can always be avoided by changing the code.
They can never be handled properly (since by definition the code in question is broken).
tried to read property of "undefined"
called an asynchronous function without a callback
passed a "string" where an object was expected
passed an object where an IP address string was expected
failure to handle an operational error is itself a programmer error.
Let's make this concrete. For any given error, there are a few things you might do:
Deal with the failure directly
Propagate the failure to your client.
Retry the operation
Blow up.
Log the error — and do nothing else
// ================================================================
Planets["Earth"].Inhabitants.OfType<Human>().....
[Naming] : http://source-code-wordle.de/NounsVariables.html
attribute
type
helper
collection
converter
handler
info
provider
exception
service
element
manager
node
option
factory
context
item
designer
base
editor
Coordinator
Builder
Writer
Reader
Handler
Container
Protocol
Target
Converter
Controller
View
Factory
Entity
Bucket