-
Notifications
You must be signed in to change notification settings - Fork 3
Description
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-sourceto 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/pathOutput:
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-sourcespfx 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.