@oconde/radar 0.4.1 → 0.4.2

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.
@@ -1217,7 +1217,7 @@ function withTimeout(promise, ms) {
1217
1217
 
1218
1218
  // src/version.ts
1219
1219
  var SDK_NAME = "@oconde/radar";
1220
- var SDK_VERSION = true ? "0.4.1" : "0.0.0-dev";
1220
+ var SDK_VERSION = true ? "0.4.2" : "0.0.0-dev";
1221
1221
 
1222
1222
  // src/client.ts
1223
1223
  var MAX_CHECK_IN_DURATION_MS = 7 * 864e5;
@@ -1807,6 +1807,12 @@ function withRequestId2(response, requestId) {
1807
1807
  }
1808
1808
  }
1809
1809
  }
1810
+ function thrownStatus(error) {
1811
+ if (typeof error !== "object" || error === null) return 500;
1812
+ const status = error.status;
1813
+ const fromKit = "location" in error || "body" in error;
1814
+ return fromKit && typeof status === "number" && Number.isInteger(status) && status >= 300 && status <= 599 ? status : 500;
1815
+ }
1810
1816
  function radarHandle(options = {}) {
1811
1817
  const client = options.client ?? radar;
1812
1818
  return async ({ event, resolve: resolveEvent }) => {
@@ -1822,7 +1828,7 @@ function radarHandle(options = {}) {
1822
1828
  try {
1823
1829
  response = await resolveEvent(event);
1824
1830
  } catch (error) {
1825
- if (client.shouldLogRequest(req)) client.logHttpRequest(context, 500);
1831
+ if (client.shouldLogRequest(req)) client.logHttpRequest(context, thrownStatus(error));
1826
1832
  throw error;
1827
1833
  }
1828
1834
  const tagged = withRequestId2(response, context.requestId);