♻️ Enhance reporting errors and warnings in parsing model token#5241
♻️ Enhance reporting errors and warnings in parsing model token#5241mikeleppane wants to merge 3 commits intorobotframework:masterfrom
Conversation
This change introduces a new type, "InvalidTokenError," to hold and represent invalid tokens while parsing source files. This improves the separation of concerns and allows better control and isolation of how invalid tokens should be handled.
…g as_warning and as_error custom constructors. Add docs to InvalidTokenError and ErrorCode types. Add appropriate unit tests for new business logic.
…quired unnecessarily to check that InvalidTokenError is Error kind and has is_fatal attribute set to true.
|
Sorry for not reviewing this in timely manner @mikeleppane due to there being more important issues in RF 7.2 scope. In the end the deprecation of the pipe-separated format (#5203) what required this enhancement was also postponed to RF 7.3. There are currently no other benefits from this change, so I believe it's best to move #5210 (and this PR) to RF 7.3 as well. There are some conflicts, but they seem to be easy to fix. |
No problem. Okay, let's move it to RF 7.3. I will fix those conflicts when I have time. While working on this and experimenting with feature proposals, I realized that there is significant room for improvement in error messages and diagnostics to enhance the developer experience (DX). This goes beyond just addressing issue #5203. Consequently, I started a side project to rewrite the parsing logic in Rust with the aim of creating a tool similar to tidy for Robot. My two main objectives are to provide great error messages and achieve high performance. |
This change introduces a new type,
InvalidTokenErrorto hold and represent invalid tokens while parsing source files. This improves the separation of concerns and allows better control and isolation of how invalid tokens should be handled.Error codes are represented by an enum (surprisingly, as a type
ErrorCode). TheInvalidTokenErrortype holds a kind parameter to describe the token's error level, which is either a warning or an error.Note: The import order is sorted because IDE does that automatically. I assume this is okay.
Related Issue