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

Method assertOk

lib.esm/utils/fetch.js:815–841  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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

Callers 4

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

Calls 3

okMethod · 0.95
toUtf8StringFunction · 0.90
assertFunction · 0.90

Tested by

no test coverage detected