"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.bracketOnError_ = exports.bracketOnError = void 0
const bracketExit_1 = require("./bracketExit")
const core_1 = require("./core")
/**
 * Executes the release effect only if there was an error.
 *
 * @dataFirst bracketOnError_
 */
function bracketOnError(use, release, __trace) {
  return (acquire) => bracketOnError_(acquire, use, release, __trace)
}
exports.bracketOnError = bracketOnError
/**
 * Executes the release effect only if there was an error.
 */
function bracketOnError_(acquire, use, release, __trace) {
  return (0, bracketExit_1.bracketExit_)(
    acquire,
    use,
    (a, e) => (e._tag === "Success" ? core_1.unit : release(a, e)),
    __trace
  )
}
exports.bracketOnError_ = bracketOnError_
//# sourceMappingURL=bracketOnError.js.map
