ts-to-io icon indicating copy to clipboard operation
ts-to-io copied to clipboard

Error: Failed to generate a codec

Open anilanar opened this issue 5 years ago • 2 comments

I have no idea what might be going wrong as the actual problem is not output.

Would you be open to some refactoring with one of the following solutions:

  1. Early exit with descriptive error message
  2. Collect error messages and output them when done

For handling/collecting errors, would you prefer Either from fp-ts or go dependency free and add another argument on the visitor such as errors: Error[]?

I'm not yet sure what might be throwing errors in handleDeclaration and what kind of errors they are, but I guess those errors can be mapped to something more descriptive with file name or original declaration string etc.

I'd like to contribute to get a t-shirt from Octoberfest 😃

anilanar avatar Oct 08 '19 11:10 anilanar

Hi, thanks for the info! The error handling side of the project – which is still in a very early stage – could indeed use some improvement. Ideally the error handling should only skip the case of the failed type and process the rest of the types normally. The current logic of catching at the handleDeclaration level enables this but could be enhanced by logging errors in more detail.

The only case I'm currently aware of that results in processType throwing is the case of recursive type declarations. At the moment there is no mechanism in place for handling such types and the result is an error. At least this one could be identified to provide better error info to the user. I'm sure there are other edge cases I haven't just encountered yet.

juusaw avatar Oct 09 '19 06:10 juusaw

#15 looks like a reasonable step towards making the parser more accessible / discoverable

ahrjarrett avatar Aug 01 '20 16:08 ahrjarrett