Skip to content

Commit 4bfff0f

Browse files
veganaiZeTrott
authored andcommitted
Clarify handling non-null as an error
1 parent e5c4aea commit 4bfff0f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

locale/en/knowledge/errors/what-are-the-error-conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ As you can see from the example, the callback is called with null as its first a
4949

5050
The `callback` function shows the reason for this: it allows a user to easily know whether or not an error occurred. If `null` was not the first argument passed on success, the user would need to check the object being returned and determine themselves whether or not the object constituted an error - a much more complex and less user-friendly approach.
5151

52-
So to wrap it all up, when using callbacks, if an error comes up, then pass it as the first argument. Otherwise, pass `null` first, and then your return arguments. On the receiving end, inside the callback function, check if the first parameter is non-null; if it is, handle it as an error.
52+
So to wrap it all up, when using callbacks, if an error comes up, then pass it as the first argument. Otherwise, pass `null` first, and then your return arguments. On the receiving end, inside the callback function, check if the first parameter is non-null. If it's non-null then handle it as an error.

0 commit comments

Comments
 (0)