Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript promise multi function error

function _inital_promise(calback) {
            return (message) => {
                return (boolean) => {
                    return new Promise((resolve,reject)=>{
                        try {
                            throw new Error(); // error
                            return resolve(message);
                        } catch (error) {
                            if (boolean) {
                                reject(error);
                            }else {
                                reject("something went wrong");
                            }
                        }
                    }).then(calback);
                }
            }
        }
        _inital_promise(console.log)("test")(false).catch(err=>console.log(err));
Source by stickynotepickles.herokuapp.com #
 
PREVIOUS NEXT
Tagged: #javascript #promise #multi #function #error
ADD COMMENT
Topic
Name
3+7 =