Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing example-parameters require better error message and error handling #2

Closed
uglow opened this issue Nov 24, 2020 · 1 comment · Fixed by #3
Closed

Missing example-parameters require better error message and error handling #2

uglow opened this issue Nov 24, 2020 · 1 comment · Fixed by #3
Assignees
Labels
bug Something isn't working released

Comments

@uglow
Copy link
Contributor

uglow commented Nov 24, 2020

Currently when an API schema indicates that it has parameters, but they are not supplied within the x-example (e.g. x-example.parameter is missing, or has less elements than the schema's parameter array), the following error is displayed:

(node:3396) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'script' of undefined
    at getParamValue (/project/node_modules/oaat/src/utils.js:271:16)
    at /project/node_modules/oaat/src/utils.js:241:32
    at Array.map (<anonymous>)
    at resolveFetchConfigParams (/projectnode_modules/oaat/src/utils.js:238:44)
    at /project/node_modules/oaat/src/utils.js:208:41
    at Readable.<anonymous> (/project/node_modules/oaat/src/utils.js:49:25)
    at Readable.emit (events.js:310:20)
    at addChunk (_stream_readable.js:286:12)
    at readableAddChunk (_stream_readable.js:268:9)
    at Readable.push (_stream_readable.js:209:10)
(node:3396) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

Additionally, the program does not exit with a non-zero exit code.

Suggested Fix

  • Show a nice error message indicating:
    • which example is incorrectly configured
  • Exit with a non-zero exit code
@uglow uglow self-assigned this Nov 24, 2020
@uglow uglow added the bug Something isn't working label Nov 24, 2020
uglow added a commit that referenced this issue Dec 2, 2020
Within the stream-processor, it was necessary to add a catch() block to catch-and-reject the Error objects being thrown.

ISSUES CLOSED: #2
@uglow uglow closed this as completed in #3 Dec 2, 2020
uglow pushed a commit that referenced this issue Dec 2, 2020
## [1.4.1](v1.4.0...v1.4.1) (2020-12-02)

### Bug Fixes

* improve error messages for missing parameters ([36a1671](36a1671)), closes [#2](#2)
@uglow
Copy link
Contributor Author

uglow commented Dec 2, 2020

🎉 This issue has been resolved in version 1.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@uglow uglow added the released label Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant