@open-mercato/shared 0.10.1-develop.8099.1.debd225eaa → 0.10.1-develop.8112.1.e94b1ab345

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.
@@ -321,14 +321,17 @@ function classifyCrudError(err) {
321
321
  async function handleError(err, request) {
322
322
  if (err instanceof Response) return err;
323
323
  if (isCrudHttpError(err)) {
324
- const { translate } = await resolveTranslations();
325
- return json(translateCrudErrorBody(err.body, translate), { status: err.status });
324
+ const { translate: translate2 } = await resolveTranslations();
325
+ return json(translateCrudErrorBody(err.body, translate2), { status: err.status });
326
326
  }
327
327
  const interceptorRejection = getCommandInterceptorHttpRejection(err);
328
328
  if (interceptorRejection) {
329
329
  return json(interceptorRejection.body, { status: interceptorRejection.status });
330
330
  }
331
- if (err instanceof z.ZodError) return json({ error: "Invalid input", details: err.issues }, { status: 400 });
331
+ const { translate } = await resolveTranslations();
332
+ if (err instanceof z.ZodError) {
333
+ return json({ error: translate("errors.invalid_input", "Invalid input"), details: err.issues }, { status: 400 });
334
+ }
332
335
  if (isTransientDbError(err)) {
333
336
  const requestId2 = resolveRequestId(request);
334
337
  logger.warn("Transient DB failure during CRUD handler", {
@@ -336,7 +339,7 @@ async function handleError(err, request) {
336
339
  requestId: requestId2
337
340
  });
338
341
  return json(
339
- { error: "Service temporarily unavailable", code: "DATABASE_UNAVAILABLE", requestId: requestId2 },
342
+ { error: translate("api.errors.databaseUnavailable", "Service temporarily unavailable"), code: "DATABASE_UNAVAILABLE", requestId: requestId2 },
340
343
  { status: 503, headers: { "Retry-After": "2", "x-request-id": requestId2 } }
341
344
  );
342
345
  }
@@ -354,7 +357,10 @@ async function handleError(err, request) {
354
357
  });
355
358
  return json(
356
359
  {
357
- error: "The record is still referenced by other data, or references a record that does not exist",
360
+ error: translate(
361
+ "api.errors.foreignKeyViolation",
362
+ "The record is still referenced by other data, or references a record that does not exist"
363
+ ),
358
364
  code: "FOREIGN_KEY_VIOLATION",
359
365
  requestId: requestId2
360
366
  },
@@ -373,8 +379,8 @@ async function handleError(err, request) {
373
379
  attributes: { requestId, errorName, code, pgCode: pgSqlState ?? void 0 }
374
380
  });
375
381
  const body = {
376
- error: "Internal server error",
377
- message: "Something went wrong. Please try again later.",
382
+ error: translate("api.errors.internal", "Internal server error"),
383
+ message: translate("api.errors.internalMessage", "Something went wrong. Please try again later."),
378
384
  requestId,
379
385
  code
380
386
  };