Skip to content

Modify the error message before calling the callback #5

@MorganLindqvist

Description

@MorganLindqvist

Hi,

I really like the node-okay module. I now would like it to support some more functionality and I would like your feedback before implementing and creating a PR.

The issue I have is that I am using an external module that does not conform to the syntax I would like to have on the error message. Today the code looks something like this.

someFunction(parameter, function(err,result){
  if(err){
    callback({error: err}); // Here I transform the syntax of err to a new format, this is just an example
  } else {
    // Do some stuff with result
    callback(null,result);
  }
}));

What I would like to have is something like the following

var errorMapping = function(value) { return { error: value}; };
someFunction(parameter, ok(callback,errorMapping,function(result){
  // Do some stuff with result
  callback(null,result);
}));

Since I have this kind of code in many places this kind of simplification would make it much more easier to write, read, and not consume so many lines.

Comments on this proposal?

Something that could land in the official node-okay repo or should I land it in a fork?

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