MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / assertOk

Method assertOk

lib.commonjs/utils/fetch.js:820–846  ·  view source on GitHub ↗

* Throws a ``SERVER_ERROR`` if this response is not ok.

()

Source from the content-addressed store, hash-verified

818 * Throws a ``SERVER_ERROR`` if this response is not ok.
819 */
820 assertOk() {
821 if (this.ok()) {
822 return;
823 }
824 let { message, error } = this.#error;
825 if (message === "") {
826 message = `server response ${this.statusCode} ${this.statusMessage}`;
827 }
828 let requestUrl = null;
829 if (this.request) {
830 requestUrl = this.request.url;
831 }
832 let responseBody = null;
833 try {
834 if (this.#body) {
835 responseBody = (0, utf8_js_1.toUtf8String)(this.#body);
836 }
837 }
838 catch (e) { }
839 (0, errors_js_1.assert)(false, message, "SERVER_ERROR", {
840 request: (this.request || "unknown request"), response: this, error,
841 info: {
842 requestUrl, responseBody,
843 responseStatus: `${this.statusCode} ${this.statusMessage}`
844 }
845 });
846 }
847}
848exports.FetchResponse = FetchResponse;
849function getTime() { return (new Date()).getTime(); }

Callers 4

#sendMethod · 0.45
_getAvatarMethod · 0.45
fetchMethod · 0.45
_sendMethod · 0.45

Calls 1

okMethod · 0.95

Tested by

no test coverage detected