Skip to content

The CLI provides different error messages when loading the main sketch file fails #1968

Open
@kittaakos

Description

@kittaakos

Describe the problem

IDE2 must gracefully handle invalid sketch (folder) names and open them even if the CLI cannot load the sketch.

Since CLI can't provide error codes (#1762), IDE2 must parse the error message of the CLI and try to detect invalid sketch name problems. (See arduino/arduino-ide#1563)

Unfortunately, the CLI's error message quite often varies. As a consumer of the CLI, I would expect that the error message is the same if the problem is the same.

To reproduce

% tree                                                                        
.
├── Bar
│   └── xxx.ino
└── foo
    └── Foo.ino

2 directories, 2 files
% ~/dev/git/arduino-ide/arduino-ide-extension/build/arduino-cli version       
arduino-cli  Version: 0.28.0 Commit: 06fb1909 Date: 2022-10-20T08:42:20Z
% ~/dev/git/arduino-ide/arduino-ide-extension/build/arduino-cli compile -b arduino:avr:uno ./Bar 
Error opening sketch: main file missing from sketch: /Users/a.kitta/Desktop/invalid-sketches/Bar/Bar.ino
% ~/dev/git/arduino-ide/arduino-ide-extension/build/arduino-cli compile -b arduino:avr:uno ./foo 
Error opening sketch: no valid sketch found in /Users/a.kitta/Desktop/invalid-sketches/foo: missing /Users/a.kitta/Desktop/invalid-sketches/foo/foo.ino
Error opening sketch: main file missing from sketch: /Users/a.kitta/Desktop/invalid-sketches/Bar/Bar.ino
Error opening sketch: no valid sketch found in /Users/a.kitta/Desktop/invalid-sketches/foo: missing /Users/a.kitta/Desktop/invalid-sketches/foo/foo.ino

Expected behavior

No matter the final error message, it's the same if I want to load, compile, etc an invalid sketch. It should no matter if it's /foo/Foo.ino or /Bar/xxx.ino invalid, it's just invalid.

Arduino CLI version

Version: 0.28.0 Commit: 06fb190 Date: 2022-10-20T08:42:20Z

Operating system

macOS

Operating system version

12.5.1

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions