@phpsandbox/sdk 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,9 +71,10 @@ var RemoteError = class _RemoteError extends PHPSandboxError {
71
71
  }
72
72
  };
73
73
  var TransportError = class _TransportError extends PHPSandboxError {
74
- constructor(message, code, cause) {
74
+ constructor(message, code, cause, response) {
75
75
  super(message, cause);
76
76
  this.code = code;
77
+ this.response = response;
77
78
  }
78
79
  static is(error51, code) {
79
80
  return error51 instanceof _TransportError && (code === void 0 || error51.code === code);
@@ -19924,7 +19925,7 @@ var ClientImplementation = class {
19924
19925
  })
19925
19926
  );
19926
19927
  if (!response.ok) {
19927
- throw remoteError("core", errorPayload(await responsePayload(response)), response);
19928
+ throw await responseError(response);
19928
19929
  }
19929
19930
  if (!response.body) {
19930
19931
  throw new TransportError("PHPSandbox API response body is not readable.", "InvalidResponse", response);
@@ -19942,7 +19943,7 @@ var ClientImplementation = class {
19942
19943
  })
19943
19944
  );
19944
19945
  if (!response.ok) {
19945
- throw remoteError("core", errorPayload(await responsePayload(response)), response);
19946
+ throw await responseError(response);
19946
19947
  }
19947
19948
  if (!response.body) {
19948
19949
  throw new TransportError("PHPSandbox API SSE response body is not readable.", "InvalidResponse", response);
@@ -19958,7 +19959,7 @@ var ClientImplementation = class {
19958
19959
  })
19959
19960
  );
19960
19961
  if (!response.ok) {
19961
- throw remoteError("core", errorPayload(await responsePayload(response)), response);
19962
+ throw await responseError(response);
19962
19963
  }
19963
19964
  if (response.status === 204) {
19964
19965
  return { data: void 0 };
@@ -19991,15 +19992,21 @@ var ClientImplementation = class {
19991
19992
  }
19992
19993
  }
19993
19994
  };
19994
- async function responsePayload(response) {
19995
+ async function responseError(response) {
19995
19996
  const body = await response.text();
19996
- if (body === "") {
19997
- return void 0;
19998
- }
19999
19997
  try {
20000
- return JSON.parse(body);
20001
- } catch (error51) {
20002
- throw new TransportError("PHPSandbox API returned an invalid JSON response.", "InvalidResponse", error51);
19998
+ return remoteError("core", errorPayload(body === "" ? void 0 : JSON.parse(body)), response);
19999
+ } catch {
20000
+ return new TransportError(
20001
+ `PHPSandbox API returned an invalid error response (HTTP ${response.status}).`,
20002
+ "InvalidResponse",
20003
+ response,
20004
+ {
20005
+ status: response.status,
20006
+ statusText: response.statusText,
20007
+ body
20008
+ }
20009
+ );
20003
20010
  }
20004
20011
  }
20005
20012
  function errorPayload(payload) {