Skip to content

Streamlined upsert with explicit NotFoundError handling and clearer logs

Choose a tag to compare

released this 25 Oct 16:18
· 33 commits to working since this release

This release focuses on simplifying the upsert flow in src/ops/upsert.ts and making not-found handling and logging more explicit.

Improvements

  • Handle not-found explicitly by importing and checking NotFoundError from @fjell/core, proceeding to the creation path when an item is missing (commit 27c7200).
  • Simplify control flow by replacing the prior existing-variable and post-fetch branching with a try/catch around get() (commit 27c7200).

Logging

  • Add a pre-fetch log message: "Retrieving item by key" before calling get() (commit 27c7200).
  • On NotFoundError, log: "Item not found, will create" (commit 27c7200).
  • Add targeted error logging for non-not-found errors: "Error getting item during upsert" (commit 27c7200).

Refactoring

  • Remove the redundant if(existing) update/else create block and the broad outer catch to tighten error handling (commit 27c7200).