Skip to content

Conversation

@Aditya-twd
Copy link

Closes #1728

This PR improves error messages when asyncapi generate fromTemplate fails while working with templates.

Changes

  • Improve error handling in GeneratorService.generate so that generator failures are surfaced as clearer, user‑friendly messages in the CLI.
  • Add a specific message when a template cannot be found or installed from the registry (for example, wrong name, missing scope, or 404‑like situations).
  • Handle cases where the template directory is missing or corrupted (for example, ENOENT on the template path) and explain that the template installation or local folder is invalid.
  • Clarify messages related to template–generator version incompatibility so users understand that a different generator or template version is required.
  • Provide more informative hints for network or registry‑related failures that occur while resolving or installing a template (for example, unreachable registry or misconfigured URL).

A screenshot of the core issue being resolved

--
Screenshot 2025-12-21 233318

Notes

The generic banner text (Something went wrong / Generation failed) is still printed by the existing CLI UI layer before the detailed Generator Error: ... message. This PR focuses on improving the generator error details and template‑related messages.

Manual testing

Manual testing is done
In order to see the issue this PR proposes to solve, follow these steps:

In the CLI repository, with a valid asyncapi.yaml in the current directory:
Run commands:

1. Non‑existent template name (template cannot be found/installed)

---> asyncapi generate fromTemplate ./asyncapi.yaml not-installed-template -o /tmp/out1

2. Unscoped template name (should be @asyncapi/html-template)

---> asyncapi generate fromTemplate ./asyncapi.yaml html-template -o /tmp/out2

3. Valid scoped template but unreachable/invalid registry URL (network/registry error)

---> asyncapi generate fromTemplate ./asyncapi.yaml @asyncapi/html-template --registry-url https://fake-registry.example.com -o /tmp/out3

@changeset-bot
Copy link

changeset-bot bot commented Dec 21, 2025

🦋 Changeset detected

Latest commit: 6d8164c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@Souvikns
Copy link
Member

@Shurtu-gal are the /src/errors/ meant to be used in the services classes. If it is then maybe move this logic to the dedicated error classes.

@AayushSaini101
Copy link
Collaborator

Kindly resolve the conflicts @Aditya-twd

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2026

@Aditya-twd
Copy link
Author

@AayushSaini101 Thanks for reviewing! I've resolved the conflicts and tested the error scenarios with the manual testing commands. The improved error messages are now working as expected. Feel free to review when you have time.

@Aditya-twd
Copy link
Author

@Shurtu-gal You're seems right! Moving this logic to dedicated error classes in /src/errors/ would be cleaner and more maintainable. I can refactor this to handle template-specific error cases there instead of in the service class. This will also make it easier to reuse and extend error handling across other services in the future.
Kindly tell me if you want me to do these changes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[Improvement]: Improve the error message while generating project fromgenerate command

3 participants