Skip to content

Replace silent failures with explicit failures in index-level.ts #633

@thehenrytsai

Description

@thehenrytsai

In index-level.ts, there are at least a couple of places where we accept invalid input and either return void/empty array instead of throwing explicit errors.

It is probably better to throw instead so that the caller does not assume the method succeeds with no results:

  1. queryWithInMemoryPaging()
      // if a cursor is provided but we cannot find it, we return an empty result set
      return [];
  1. getStartingKeyForCursor()
    if (indexes === undefined) {
      // invalid itemId
      return;
    }

    const sortValue = indexes[property];
    if (sortValue === undefined) {
      // invalid sort property
      return;
    }

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomershacktoberfestFor the hacking month of OctoberrefactoringCode refactoring with no functional impact

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions