mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
throw error objects instead of plain strings, update wisp server
This commit is contained in:
parent
3c1a942501
commit
c1b78e1d0c
11 changed files with 16 additions and 15 deletions
|
@ -67,13 +67,13 @@ class HTTPSession extends CurlSession {
|
|||
}
|
||||
if (error > 0) {
|
||||
error_msg(`Request "${url}" failed with error code ${error}: ${get_error_str(error)}`);
|
||||
reject(`Request failed with error code ${error}: ${get_error_str(error)}`);
|
||||
reject(new TypeError(`Request failed with error code ${error}: ${get_error_str(error)}`));
|
||||
}
|
||||
else if (error === -1) {
|
||||
reject(new DOMException("The operation was aborted."));
|
||||
}
|
||||
else if (error === -2) {
|
||||
reject("Request failed because redirects were disallowed.");
|
||||
reject(new TypeError("Request failed because redirects were disallowed."));
|
||||
}
|
||||
this.remove_request(http_handle);
|
||||
http_handle = null;
|
||||
|
|
|
@ -139,7 +139,7 @@ api = {
|
|||
CurlWebSocket: CurlWebSocket,
|
||||
TLSSocket: TLSSocket,
|
||||
HTTPSession: HTTPSession,
|
||||
fetch() {throw "not ready"},
|
||||
fetch() {throw new Error("not ready")},
|
||||
|
||||
get copyright() {return copyright_notice},
|
||||
get version() {return get_version()},
|
||||
|
|
|
@ -24,7 +24,7 @@ class CurlSession {
|
|||
|
||||
assert_ready() {
|
||||
if (!this.session_ptr) {
|
||||
throw "session has been removed";
|
||||
throw new Error("session has been removed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ function data_to_array(data) {
|
|||
return new Uint8Array(data.buffer);
|
||||
}
|
||||
|
||||
throw "invalid data type to be sent";
|
||||
throw new TypeError("invalid data type to be sent");
|
||||
}
|
||||
|
||||
//c function wrapper
|
||||
|
|
|
@ -62,7 +62,7 @@ class FakeWebSocket extends EventTarget {
|
|||
converted = data.buffer;
|
||||
}
|
||||
else {
|
||||
throw "invalid binaryType string";
|
||||
throw new TypeError("invalid binaryType string");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue