Skip to content

[doc bug] StateNotConstructed not documented and hard to find the right incatation to import #27

@katfang

Description

@katfang

Describe the bug

StateNotConstructed (and potentially other errors reboot throws) is either not in the docs, or the search doesn't turn them up, which makes it hard to know how to catch and handle the error.

Reboot server spat out

Exiting: LocPieceIndexGetAborted: rbt.v1alpha1.StateNotConstructed
    at Function.fromStatus (/Users/katfang/reboot/cheaoss/api/cheaoss/v1/piece_rbt.ts:2053:14)
    at LocPieceIndexWeakReference.__externalServiceCallGet (/Users/katfang/reboot/cheaoss/api/cheaoss/v1/piece_rbt.ts:3134:10)
    at async LocPieceIndexWeakReference.get (/Users/katfang/reboot/cheaoss/api/cheaoss/v1/piece_rbt.ts:3144:18)
    at async validateMoveWithBoard (/Users/katfang/reboot/cheaoss/backend/src/piece_servicer.ts:189:29) {
  error: StateNotConstructed { requiresConstructor: false },
  code: 10
}
unhandled error in runQueue PieceMovePieceAborted: rbt.v1alpha1.Unavailable: Socket closed
    at Function.fromStatus (/Users/katfang/reboot/cheaoss/api/cheaoss/v1/piece_rbt.ts:1781:14)
    at PieceWeakReference.__externalServiceCallMovePiece (/Users/katfang/reboot/cheaoss/api/cheaoss/v1/piece_rbt.ts:2587:10)
    at async PieceWeakReference.movePiece (/Users/katfang/reboot/cheaoss/api/cheaoss/v1/piece_rbt.ts:2597:18)
    at async GameServicer2.runQueue (/Users/katfang/reboot/cheaoss/backend/src/game_servicer.ts:322:7)
    at async Module.runWithContext (file:///Users/katfang/reboot/cheaoss/node_modules/@reboot-dev/reboot/index.js:138:12)
    at async GameServicer2._RunQueue (/Users/katfang/reboot/cheaoss/api/cheaoss/v1/game_rbt.ts:452:24) {
  error: Unavailable {},
  code: 14
}

Which is cool. The state not being constructed is not a problem, but I would like to catch it because that's a valid state to be in for me.

The following worked for me:

import { errors_pb } from "@reboot-dev/reboot-api";

// ...

      try {
        await LocPieceIndex.ref(refId).get(context);
      } catch (e) {
        if (e instanceof LocPieceIndex.GetAborted && e.error instanceof errors_pb.StateNotConstructed) {
          // handling non existence
        }
      }

Related to reboot-dev/mono#3943

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to call a reader method on a state id that doesn't exist.

Expected behavior

I expect the docs to tell me what errors can be thrown by Reboot itself (and ideally have examples for how I can import / catch them myself).

Impact
How severely does this bug impact your use of Reboot?

  • It's not having any negative impact
  • It's annoying
  • It's a serious problem
  • It makes it impossible for me to use Reboot

I only figured out the import via trial and error and some searching of StateNotConstructed in the docs (not found by search) and the repo (which is how I decided, maybe I attempting to import errors_pb instead of StateNotConstructed would work)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions