svd icon indicating copy to clipboard operation
svd copied to clipboard

Better error handling

Open Emilgardis opened this issue 8 years ago • 5 comments

See related issue japaric/svd2rust#51 svd-parser uses Option<String> for ElementExt::get_child_text, and an expect is done with the defined try! macro in lib.rs, avoiding any way of knowing what had gone wrong. I propose for svd-parser to use error-chain to fix this problem, but also to use a logging crate to make debugging svd errors easier for the user without having to use utilities like SVDConv.exe to check for errors in the svd file and to see if the error is by missing implementation in svd2rust.

Emilgardis avatar Jan 08 '17 18:01 Emilgardis

I have a WIP branch that does this. It is not exactly what I would like it to be currently, but it gives me a much better picture of what happened on an error.

Emilgardis avatar Jan 29 '17 21:01 Emilgardis

I'm going to wait for japaric/svd2rust#53 and then rebase my branch. I have also implemented #21 on that branch, it should be on a separate pr.

Emilgardis avatar Feb 05 '17 21:02 Emilgardis

Hello,

Whats the state of this issue? I am trying to generate a PAC for the VA108xx device by using their svd files and I think something like a line number for this error

[ERROR svd2rust] expected `,`

would help

robamu avatar Oct 28 '21 20:10 robamu

This has been done, but it could be improved upon, I dont think we can capture line numbers currently, but I will check. I'll return to you in your other comment on issue #41

Emilgardis avatar Oct 29 '21 07:10 Emilgardis

I have dug a little bit deeper and I can confirm that the error comes from the syn crate when calling generate::device::render. The precise error happens at convert_svd_register / name_to_wrapped_ty . I would say this needs to be fixed in svd2rust then but I don't know the data structure generated by the parser well enough to say whether any of the data returned in "invalid"

robamu avatar Oct 29 '21 18:10 robamu