MCPcopy Create free account
hub / github.com/TruthHun/BookStack / finallyHandler

Function finallyHandler

static/word2md/mammoth.browser.js:5917–5956  ·  view source on GitHub ↗
(reasonOrValue)

Source from the content-addressed store, hash-verified

5915 return errorObj;
5916}
5917function finallyHandler(reasonOrValue) {
5918 var promise = this.promise;
5919 var handler = this.handler;
5920
5921 if (!this.called) {
5922 this.called = true;
5923 var ret = this.isFinallyHandler()
5924 ? handler.call(promise._boundValue())
5925 : handler.call(promise._boundValue(), reasonOrValue);
5926 if (ret !== undefined) {
5927 promise._setReturnedNonUndefined();
5928 var maybePromise = tryConvertToPromise(ret, promise);
5929 if (maybePromise instanceof Promise) {
5930 if (this.cancelPromise != null) {
5931 if (maybePromise._isCancelled()) {
5932 var reason =
5933 new CancellationError("late cancellation observer");
5934 promise._attachExtraTrace(reason);
5935 errorObj.e = reason;
5936 return errorObj;
5937 } else if (maybePromise.isPending()) {
5938 maybePromise._attachCancellationCallback(
5939 new FinallyHandlerCancelReaction(this));
5940 }
5941 }
5942 return maybePromise._then(
5943 succeed, fail, undefined, this, undefined);
5944 }
5945 }
5946 }
5947
5948 if (promise.isRejected()) {
5949 checkCancel(this);
5950 errorObj.e = reasonOrValue;
5951 return errorObj;
5952 } else {
5953 checkCancel(this);
5954 return reasonOrValue;
5955 }
5956}
5957
5958Promise.prototype._passThrough = function(handler, type, success, fail) {
5959 if (typeof handler !== "function") return this.then();

Callers

nothing calls this directly

Calls 2

tryConvertToPromiseFunction · 0.70
checkCancelFunction · 0.70

Tested by

no test coverage detected