@@ -128,35 +128,36 @@ they are thrown *after* the calling code has already exited.
128128Developers must refer to the documentation for each method to determine
129129exactly how errors raised by those methods are propagated.
130130
131- ### Node.js style callbacks
131+ ### Error-first callbacks
132132
133133<!-- type=misc-->
134134
135135Most asynchronous methods exposed by the Node.js core API follow an idiomatic
136- pattern referred to as a "Node.js style callback". With this pattern, a
137- callback function is passed to the method as an argument. When the operation
138- either completes or an error is raised, the callback function is called with
139- the Error object (if any) passed as the first argument. If no error was raised,
140- the first argument will be passed as ` null ` .
136+ pattern referred to as an _ error-first callback_ (sometimes referred to as
137+ a _ Node.js style callback_ ). With this pattern, a callback function is passed
138+ to the method as an argument. When the operation either completes or an error
139+ is raised, the callback function is called with
140+ the Error object (if any) passed as the first argument. If no error was
141+ raised, the first argument will be passed as ` null ` .
141142
142143``` js
143144const fs = require (' fs' );
144145
145- function nodeStyleCallback (err , data ) {
146+ function errorFirstCallback (err , data ) {
146147 if (err) {
147148 console .error (' There was an error' , err);
148149 return ;
149150 }
150151 console .log (data);
151152}
152153
153- fs .readFile (' /some/file/that/does-not-exist' , nodeStyleCallback );
154- fs .readFile (' /some/file/that/does-exist' , nodeStyleCallback );
154+ fs .readFile (' /some/file/that/does-not-exist' , errorFirstCallback );
155+ fs .readFile (' /some/file/that/does-exist' , errorFirstCallback );
155156```
156157
157158The JavaScript ` try / catch ` mechanism ** cannot** be used to intercept errors
158159generated by asynchronous APIs. A common mistake for beginners is to try to
159- use ` throw ` inside a Node.js style callback:
160+ use ` throw ` inside an error-first callback:
160161
161162``` js
162163// THIS WILL NOT WORK:
0 commit comments