JSFiddle - React, Tailwind, and code Playground

JavaScript

function Executor(program, args, success, error){
  this.program = program;
  this.args = args;
  if (typeof success === 'function'){
    this.success = success;
  } else {
    this.success = function(){
      console.log('OK');
    }
  }
  if (typeof error === 'function'){
    this.error = error;
  } else {
    this.error = function(err){
      throw new Error(err);
    }
  }
  this.execute = function(){
    console.log('calling ' + this.program + ' with args: ' + JSON.stringify(this.args));
    this.success();
    this.error('net, eto peka!');
  }
}

var yoba = new Executor('yoba', {allo:'eto ti?'}, undefined, function(err){
  console.log(err);
});

yoba.execute();