R.otherwise(onFailure, promise) is Ramda’s curried .catch: it runs onFailure when a Promise rejects, and returns a new Promise. On success, the original value passes through unchanged.
Stable:R.otherwise has been in Ramda since v0.26.0. It is not deprecated, experimental, or non-standard. Pair with R.andThen for the success path.
Syntax
Call R.otherwise. Start with this line.
Ramda
R.otherwise(onFailure, promise)
Call
What it does
R.otherwise(onFailure, promise)
Primary signature.
R.otherwise(...)
Call the function helper.
Prefer import { otherwise } from "ramda" when you want a named import.
Library declarations
Ramda
R.otherwise(onFailure, promise)
Parameters
Parameter
Description
onFailure
Required. Runs on reject; may return a value or Promise
p
Required. A Promise (must have .then)
Return Value
Return Value
Description
*
New Promise from p.then(null, onFailure)
Ramda Examples
Example 1 — Official recoverFromFailure
A fetch that always rejects. Recover with a default member, then pick the name fields.
Requirement. The second argument must be thenable.
Pipe tip. Put otherwise only after a step that returns a Promise.
Not async. This is not a rejected Promise — it is a synchronous TypeError.
Compatibility
Browser & Runtime Support
R.otherwise is a Ramda Function helper since v0.26.0. It builds on native Promises (.then). It runs anywhere Ramda 0.26+ and Promises are available.
✓ Stable · Ramda 0.26.0+
R.otherwise()
Needs Ramda 0.26+ and a Promise-capable runtime. Works in evergreen browsers and current Node LTS / Bun / Deno when Ramda is installed.
100%With Ramda 0.26+ & Promises
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
R.otherwiseRamda 0.26.0+
Bottom line: Safe for production once Ramda 0.26.0+ is loaded in a Promise environment. Use a CDN build such as ramda.min.js in the browser, or npm install ramda for Node. Very old browsers without Promises need a Promise polyfill.
Frequently Asked Questions
R.otherwise(onFailure, promise) returns promise.then(null, onFailure). It runs onFailure when the Promise rejects, and returns a new Promise. If the original Promise resolves, onFailure is skipped and the success value passes through. Added in v0.26.0. See also R.andThen.
andThen is the success path: promise.then(onSuccess). otherwise is the failure path: promise.then(null, onFailure). Put otherwise before andThen in a pipe when you want to recover, then transform the recovered value.
No. A resolved Promise skips onFailure. R.otherwise(R.always('fallback'), Promise.resolve('ok')) still resolves to 'ok'.
Ramda throws a TypeError: `otherwise` expected a Promise, received … The second argument must have a .then method.
No. R.otherwise is a stable Ramda Function helper from v0.26.0. It is not deprecated, experimental, or non-standard.