hono-utils 0.3.7 → 0.3.8

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.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
3
  for (var name in all)
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -14216,7 +14216,7 @@ var onError = (parseError) => async (err, { json: json2, env, get }) => {
14216
14216
  const status = "status" in err ? err.status : 500;
14217
14217
  return json2(
14218
14218
  {
14219
- message: !parseError ? err.message : await parseError(err, env, get)
14219
+ message: !parseError ? err.message : await _asyncNullishCoalesce(await parseError(err, env, get), async () => ( defaultMessageMap.internalError))
14220
14220
  },
14221
14221
  status
14222
14222
  );
@@ -14256,21 +14256,19 @@ var createTypedClient = () => {
14256
14256
  _optionalChain([callbacks, 'optionalAccess', _194 => _194.onSuccess, 'optionalCall', _195 => _195(data, responseHeaders)]);
14257
14257
  return data;
14258
14258
  } catch (err) {
14259
- const errorBody = { message: err.message };
14260
14259
  let status = 500;
14261
- if (err instanceof _client.DetailedError) {
14262
- const { detail, statusCode } = err;
14263
- status = _nullishCoalesce(statusCode, () => ( 500));
14264
- if (!detail) {
14265
- _optionalChain([options, 'access', _196 => _196.errorHandler, 'optionalCall', _197 => _197(500, {
14266
- message: "Fetch malformed"
14267
- })]);
14268
- throw new (0, _httpexception.HTTPException)(500, { message: "Fetch malformed" });
14269
- }
14270
- }
14271
- _optionalChain([callbacks, 'optionalAccess', _198 => _198.onError, 'optionalCall', _199 => _199(errorBody, responseHeaders)]);
14272
- _optionalChain([options, 'access', _200 => _200.errorHandler, 'optionalCall', _201 => _201(status, errorBody)]);
14273
- throw new (0, _httpexception.HTTPException)(status, errorBody);
14260
+ const { detail, statusCode } = err;
14261
+ status = _nullishCoalesce(statusCode, () => ( 500));
14262
+ if (!detail) {
14263
+ _optionalChain([options, 'access', _196 => _196.errorHandler, 'optionalCall', _197 => _197(status, {
14264
+ message: "Fetch malformed"
14265
+ })]);
14266
+ throw new (0, _httpexception.HTTPException)(status, { message: "Fetch malformed" });
14267
+ }
14268
+ const { message } = detail;
14269
+ _optionalChain([options, 'access', _198 => _198.errorHandler, 'optionalCall', _199 => _199(status, { ...detail, status })]);
14270
+ _optionalChain([callbacks, 'optionalAccess', _200 => _200.onError, 'optionalCall', _201 => _201(detail, responseHeaders)]);
14271
+ throw new (0, _httpexception.HTTPException)(status, { message });
14274
14272
  } finally {
14275
14273
  _optionalChain([callbacks, 'optionalAccess', _202 => _202.onEnd, 'optionalCall', _203 => _203()]);
14276
14274
  }