Open
Description
Describe the request
The CLI can programmatically indicate when the InitRequest
has failed: arduino/arduino-cli#2076
IDE2 should eliminate the error-prone message parsing and use error codes to be more robust.
Describe the current behavior
IDE2 parsers the English error message and try to detect the error. This can be problematic when the user's default CLI language is other than English.
Arduino IDE version
2.0.4
Operating system
macOS
Operating system version
12.6.3
Additional context
No response
Issue checklist
- I searched for previous requests in the issue trackerI verified the feature was still missing when using the latest nightly buildMy request contains all necessary details
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
kittaakos commentedon Feb 28, 2023
IDE2 cannot yet adapt the changes: arduino/arduino-cli#2076
On IDE2's side, we have to figure out how to convert such messages to objects in a generic way assuming the client does not know what the type is:
Something like this works, but the error types are unknown upfront
protocolbuffers/protobuf-javascript#68 (comment)
cmaglie commentedon Feb 28, 2023
In golang, we call the
UnmarshalNew()
method from one of thedetails
elements (that is of actual type*anypb.Any
) to get a concrete object and, after that, we do a type assertion to get the actual error.Here the go snippet:
this outputs:
I'm not familiar with the JS binding, Is there a similar method in JS?
Maybe we could have a call to figure this out?
kittaakos commentedon Feb 28, 2023
Thanks for the snippet. I have not yet found the JS equivalent of:
At least, JS can switch on the
typeUrl
string, but as I wrote in #1925 (comment), it's suboptimal because the client should know the possible errors. If you check the gRPC API changes from arduino/arduino-cli#2076, you can see that there are two new messages types,FailedInstanceInitError
andPlatformLoadingError
, but they are not referenced. So from the sole proto API, clients do not know what can be an error.kittaakos commentedon Feb 28, 2023
I posted a hack to https://stackoverflow.com/questions/75592630/can-grpc-grpc-js-dynamically-unpack-google-protobuf-any-type
feat: error handling from CLI status#details
feat: error handling from CLI status#details