Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Provide error code when a function call has failed #1206

Copy link
Copy link
@rcjsuen

Description

@rcjsuen
Issue body actions
return git.Merge.base(repo, parents[0], parents[1]);
.then(function(ancestor) {
  console.log(ancestor);
})
.catch(function(err) {
  console.log(err);
})

Running the code above will print out the output below if the two commits have no common ancestor.

[Error: No merge base found]

The error code behind this error is Error.CODE.ENOTFOUND but there is no way for a client to know this. Not having a common ancestor between two commits is an error that a client may be able to handle gracefully but if it the function failed because of some other fatal error then maybe the client can't do anything about it. Without an error code available in the catch callback, clients have no way of figuring out why the function failed outside of parsing the error message itself. It would be nice if we could have something like either of the two following patterns...

catch(function(err, code) {
  console.log(err);
  console.log(code);
});
catch(function(err) {
  console.log(err.msg);
  console.log(err.code);
});
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.