beginner-corp / begin-data

A durable and fast key/value store for Begin built on top of DynamoDB
79 stars 8 forks source link

Improve error message if `data` table is not present #117

Open ryanblock opened 10 months ago

ryanblock commented 10 months ago

Currently, if the data table required by Begin Data is not present, you may get an unhelpful error such as

/path/to/project/node_modules/@aws-lite/client/src/error.js:13
  let err = error instanceof Error ? error : Error()
                                             ^
ParameterNotFound: @aws-lite/client: SSM.GetParameter: unknown error
    at errorHandler (/path/to/project/node_modules/@aws-lite/client/src/error.js:13:46)
    at GetParameter (/path/to/project/node_modules/@aws-lite/client/src/client-factory.js:211:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  statusCode: 400,
  headers: {
    'content-type': 'application/json',
    date: 'Sat, 03 Feb 2024 20:51:57 GMT',
    connection: 'close',
    'content-length': '45'
  },
  __type: 'ParameterNotFound',
  code: 'ParameterNotFound',
  service: 'ssm',
  property: 'SSM',
  awsDoc: 'https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameter.html',
  readme: 'https://aws-lite.org/services/ssm#getparameter',
  time: '2024-02-03T20:51:57.603Z'
}

We should improve that output as it is not helpful.

See: https://github.com/beginner-corp/begin-data/blob/main/src/helpers/_get-table-name.js#L45