I have a couple of async method that is basically a yes and no replyisUsernameAvalible() isOnline() isImage() yada yada... you probably get the point by now.As a demonstration... try to think of this as a more generic async promise handling (not that it has anything to do with image manipulation) and it could be working kind of the same way for eg isOnline(id).then(showOn, showOff)function isImage (file) {    return new Promise(resolve => {        let img = new Image        img.src = URL.createObjectURL(file)        img.onload = () => resolve(true)        img.onerror = () => resolve(false)    })}function showError () {    // alert(not an image)}input.onchange = evt => {    isImage(evt.target.files[0]).then(isImage => {        isImage ? convert() : showError()    }, err => {        // code execution failed        // couldn't tell if it's a image or not        //         // alert(unknown error)        // URL.createObjectURL is not a function    })}vsfunction isImage (file) {    return new Promise((resolve, reject) => {        let img = new Image        img.src = URL.createObjectURL(file)        img.onload = () => resolve(true)        img.onerror = () => reject(new Error('Not a image file'))    })}function showError (error) {    // alert(instanceof error)}input.onchange = evt => {    // This becomse a bit more nicer to read and write    isImage(evt.target.files[0]).then(convert, showError)}I feel like the second method is a nicer way to deal with it. But I misuse use the way of how promises should deal with errorsI feel like isSomething() should resolve to a boolean true/false and reject if there is any code execution error. Like unable to make GET requestWhat do you think?
Which of these promise methods is considered a best practice?
javascript;promises