Skip to content

Error message for failed template fetch incorrectly suggests --local-source when user is already using it #178

@nick-pape

Description

@nick-pape

Summary

When list-templates (or create) fails to fetch templates and the user has already provided --local-source, the error message still says:

If you are offline or behind a firewall, use --local-source to specify a local template source.

This is confusing when the failure is caused by a bad --local-source path (e.g. a typo), not a network issue.

Reproduction

spfx list-templates --local-source /nonexistent/path

Output:

Error listing templates: Failed to fetch templates. If you are offline or behind a firewall,
use --local-source to specify a local template source. Details: Failed to read templates from
/nonexistent/path: Error: File does not exist: /nonexistent/path

Expected behavior

The message should be context-aware. If the failure is a local filesystem error (not a network error), the hint should describe the actual problem rather than suggesting the flag the user already used. At minimum, distinguish between network fetch failures and local read failures.

Affected commands

  • spfx list-templates --local-source
  • spfx create --local-template (same error-wrapping pattern)

Notes

The current implementation uses a single catch block for getTemplatesAsync() and applies the same error message regardless of which source failed. A fix would likely need to either catch errors per-source or inspect the error type to determine the right hint.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions