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

Improve error message due to missing FQBN in upload/compile commands #540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

federicobond
Copy link
Contributor

@federicobond federicobond commented Jan 5, 2020

No description provided.

@federicobond federicobond force-pushed the handle-sketch-json branch 3 times, most recently from 0bce37c to b1a8581 Compare January 8, 2020 17:12
@federicobond federicobond changed the title Handle FQBNs provided via sketch.json files in upload/compile commands Improve error message due to missing FQBN in upload/compile commands Jan 8, 2020
@federicobond
Copy link
Contributor Author

@masci this is the PR I mentioned in #545

@masci masci added this to the 0.8.0 milestone Jan 9, 2020
@masci masci modified the milestones: 0.8.0, 0.9.0 Feb 14, 2020
@rsora rsora modified the milestones: 0.9.0, 0.10.0 Feb 21, 2020
@rsora
Copy link
Contributor

rsora commented Mar 26, 2020

Hi @federicobond, I gave a look at your PR, good job!

I was wondering if you want to modify your PR to try another approach for giving better error info to our users:

We moved recently the fqbn / port / sketch folder checks a level below in the commands module , to better support both the CLI and the gRPC interface.

To maintain a "Single Responsibility Principle" we think it could be better to:

  1. create an error type alias in the commands package that represents the MissingFqbnError (see this for example
  2. replace your error check in the cli/compile/compile.go and cli/upload/upload.go with an error check that leverages type checking to inspect the error returned from the compile.Compile() and upload.Upload() functions, for example using a switch err.(type) { construct

WDYT?

Thanks for your contribution and happy coding!

@federicobond
Copy link
Contributor Author

Hi, thank you for the feedback, @rsora! One problem I see with that approach is that the error type would not be serialized through the gRPC interface, right? The error message string would, but its type would be lost in the translation.

@federicobond
Copy link
Contributor Author

federicobond commented Mar 27, 2020

I do get your point about the Single Responsibility Principle though, and I am similarly bothered by the duplication we see here, but it's not at all uncommon to have this sort of duplication in other client/server architectures.

Sometimes clients are able to provide richer feedback and developers can take advantage of that, which usually requires some duplication of logic. Sometimes they are not, but it's important that users still receive some feedback from the backend.

Edit: we could do something like this instead.

@rsora
Copy link
Contributor

rsora commented Apr 2, 2020

Hi @federicobond,
I gave a look to the document you posted (thanks for suggesting!) and tried to bind errors generated in the commands packages with codes from the package mentioned in the blog post you shared, to imagine how a possible implementation could be.

I ended up having a lot of Internal Code = 13 errors, because commands modules are fairly high level modules, that wraps different errors coming from low level modules that cannot be identified at commands level.

Additionally, we cannot use the status package outside the commands because we want to avoid leaks of gRPC specific structures in the arduino-cli internals as much as possible.

So, if we need to continue on this path, I guess we should define specific error type alias for both commands and lower level modules and use them to:

  • create status errors in case of gRPC to send back to client with all the details
  • identify the specific error type at command line interface level and generate a proper CLI message for the user.

What do you think about implementing a POC for this approach? This way we can continue the discussion having some code to look at.

Thanks for your suggestion!

@federicobond
Copy link
Contributor Author

Sure! I can try a POC of that. It will probably happen in the weekend though, feeling exhausted these days during the weeks.

@rsora rsora modified the milestones: 0.10.0, 0.11.0 Apr 14, 2020
@umbynos umbynos modified the milestones: 0.11.0, 0.12.0 Jun 17, 2020
@cmaglie cmaglie modified the milestones: 0.12.0, 0.14.0 Sep 14, 2020
@per1234 per1234 added component/CLI type: enhancement Proposed improvement labels Feb 3, 2021
@github-actions github-actions bot closed this Mar 30, 2021
@per1234 per1234 reopened this Mar 30, 2021
@silvanocerza silvanocerza removed this from the 0.14.0 milestone May 11, 2021
@rsora rsora added topic: CLI Related to the command line interface and removed topic: CLI labels Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants