paritytech / opstooling-js

Shared functionality for OpsTooling projects
https://www.npmjs.com/package/@eng-automation/js
Apache License 2.0
0 stars 1 forks source link

Adding a status check to validatedFetch #10

Closed mutantcornholio closed 2 years ago

mutantcornholio commented 2 years ago

Even though there is an indication of the error in the message, a ValidationError threw me off a bit

Error before:

ERROR (app): Caught exception while executing the handler for "push" ~@ Context: { eventId: '7ace4d2e-eca6-11ec-889d-ad6ccbd716ab', eventName: 'push' } {
  stack: 'ValidationError: "content" is required',
  message: '"content" is required',
  _original: { message: '404 Project Not Found' },
  details: [
    {
      message: '"content" is required',
      path: [Array],
      type: 'any.required',
      context: [Object]
    }
  ]
}

Error after:

ERROR (app): Caught exception while executing the handler for "push" ~@ Context: { eventId: '7ace4d2e-eca6-11ec-889d-ad6ccbd716ab', eventName: 'push' } {
  stack: 'Error: Unexpected code: 404. Url: https://testlab.parity.io/api/v4/projects/123/repository/files/gitspiegel.yml?ref=master. Body: {"message":"404 Project Not Found"}\n' +
    '    at file:///Users/cornholio/work/parity/gitspiegel/node_modules/opstooling-js/dist/index.mjs:1157:13\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
    '    at async validatedFetch (file:///Users/cornholio/work/parity/gitspiegel/node_modules/opstooling-js/dist/index.mjs:1154:16)\n' +
    '    at async file:///Users/cornholio/work/parity/gitspiegel/src/configuration.ts:156:31\n' +
    '    at async reloadConfiguration (file:///Users/cornholio/work/parity/gitspiegel/src/configuration.ts:155:9)\n' +
    '    at async file:///Users/cornholio/work/parity/gitspiegel/src/core.ts:417:37\n' +
    '    at async mirrorRef (file:///Users/cornholio/work/parity/gitspiegel/src/core.ts:416:21)\n' +
    '    at async Object.onPush [as push] (file:///Users/cornholio/work/parity/gitspiegel/src/handlers.ts:131:3)\n' +
    '    at async handleEvent (file:///Users/cornholio/work/parity/gitspiegel/src/bot.ts:30:5)',
  message: 'Unexpected code: 404. Url: https://testlab.parity.io/api/v4/projects/123/repository/files/gitspiegel.yml?ref=master. Body: {"message":"404 Project Not Found"}'
}