Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

catch backend errors in 'get' or 'getOrElse' and follow 'orElse' when they occur #3

Merged
merged 2 commits into from
Apr 17, 2014

Conversation

Kofia5
Copy link

@Kofia5 Kofia5 commented Apr 17, 2014

Timeouts and other errors in getWrapped currently cause errors/rejections that are passed all the way through to the callback in getOrElse - The expected behavior is more likely to be that the passed-in value or value function is used in the case of any problems retrieving the given key.

obj =
errorGenerator: (callback) -> callback(new Error('backend troubles'))

bond(cache, 'getWrapped').return(Q.npost(obj, "errorGenerator"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be written as: bond(cache, 'getWrapped').return Q.reject new Error('backend troubles'). This makes the function return a rejected promise ("throw an error").

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated (forgot which email these updates go to, just read it)

@jkrems
Copy link
Contributor

jkrems commented Apr 17, 2014

Small stylistic note, otherwise looks good!

@jkrems
Copy link
Contributor

jkrems commented Apr 17, 2014

LGTM! Will publish as bug fix.

jkrems added a commit that referenced this pull request Apr 17, 2014
catch backend errors in 'get' or 'getOrElse' and follow 'orElse' when they occur
@jkrems jkrems merged commit 259a141 into groupon:master Apr 17, 2014
@Kofia5 Kofia5 deleted the get-fallback branch April 17, 2014 20:31
@jkrems
Copy link
Contributor

jkrems commented Apr 17, 2014

v2.0.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants