Is there a reason to return a structured object that contains an error / value property instead of using the more standard resolved / rejected promise that works with normal JS error handling flows? Are the Promises you're returning guaranteed to never throw an error?
I'm finding it makes it easy to miss error handling as it not the standard try / catch usually seen with async functions.
The design seems to be forcing a lot of duplicate handling of errors, e.g.:
try {
const result = await storage.addFileFromBuffer(...)
if (result.error) handleErrors(result.error)
else doSomethingElse(result.value)
} catch (err) {
handleError(err)
}
Is there a reason to return a structured object that contains an
error/valueproperty instead of using the more standard resolved / rejected promise that works with normal JS error handling flows? Are the Promises you're returning guaranteed to never throw an error?I'm finding it makes it easy to miss error handling as it not the standard try / catch usually seen with async functions.
The design seems to be forcing a lot of duplicate handling of errors, e.g.: