Promises without `.then`

Conceptually, there’s nothing wrong with an operation that only has an error handler and has nothing else to do upon successful completion. If that’s all it needs, then that’s fine. For example, suppose you’re updating a server with some new data from the client. If the data is successfully sent to the server, there’s nothing else to do because the operation is complete, but if there’s an error, then there is perhaps something else to do (retry, inform the user, correct the data based on the error code, etc…).

To comment on whether that’s the right way to design your specific code, we’d have to see the actual code and understand what it is doing and then form an opinion on whether that is the best way to structure that specific code.

If I was designing a general purpose function, I’d certainly provide both completion (resolving the promise) and error (rejecting the promise) so the caller could hook into either one. But it is really up to the caller which events they want to know about and if only the error matters, then just having a .catch() is fine.

Leave a Comment