import { assert } from "../../../shared/src/asserts.js";
class ChunkNotFoundError extends Error {
  name = "ChunkNotFoundError";
  hash;
  constructor(hash) {
    super(`Chunk not found ${hash}`);
    this.hash = hash;
  }
}
async function mustGetChunk(store, hash) {
  const chunk = await store.getChunk(hash);
  if (chunk) {
    return chunk;
  }
  throw new ChunkNotFoundError(hash);
}
async function mustGetHeadHash(name, store) {
  const hash = await store.getHead(name);
  assert(hash, `Missing head ${name}`);
  return hash;
}
export {
  ChunkNotFoundError,
  mustGetChunk,
  mustGetHeadHash
};
//# sourceMappingURL=store.js.map
