Skip to content

Not using error-first callbacks #4

@vladaman

Description

@vladaman

In general callbacks are expected to return error first.

There’s really only two rules for defining an error-first callback:

  1. The first argument of the callback is reserved for an error object. If an error occurred, it will be returned by the first err argument.
  2. The second argument of the callback is reserved for any successful response data. If no error occurred, err will be set to null and any successful data will be returned in the second argument.

Current:

try {
            var res = JSON.parse(body);
            callback(res, false);
        } catch (e) {
            callback(false, { error: body } );
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions