Conversation
tothtamas28
left a comment
There was a problem hiding this comment.
Is this change preparing for a specific feature? At the moment, all error types still just wrap a String, but this makes the code more complex and increases coupling between the modules.
| pub enum KError { | ||
| KoreLexerError(String), | ||
| KoreParseError(String), | ||
| } |
There was a problem hiding this comment.
Consider defining pub struct KoreLexerError in lexer.rs and pub struct KoreParserError in parser.rs. This reduces coupling between the two modules and keeps error definitions close to their source.
There doesn’t seem to be a strong need to handle these two errors uniformly. But even if such a need exists, you can still define a wrapper type:
pub enum KError {
ParserError(KoreParserError),
LexerError(KoreLexerError),
}|
|
||
| impl Id { | ||
| pub fn new(s: String) -> Result<Self, String> { | ||
| pub fn new(s: String) -> Result<Self, KError> { |
There was a problem hiding this comment.
As long as it serves its purpose, I think it's reasonable to keep the error as a String here. Clients of this type can still convert or wrap the error however they see fit.
I guess at the moment I'm unsure what the best way to handle errors are. My idea was to make one generic error enum that can be extended with any new variants that are needed in the library, and extending Your concern about coupling makes sense, though. This would make a lot of modules depend on I am trying to create python bindings for the kore structures. The library I am using (pyo3) has a |
No description provided.