-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement file parsing error handling
This PR implements proper file parsing error handling. Previously `file_options` would call `pm_string_mapped_init` which would print an error from `perror`. However this wouldn't raise a proper Ruby error so it was just a string output. I've done the following: - Update `pm_string_mapped_init` to delete `perror` and instead of returning `true` or `false` return the `errno` or `0`. - `pm_string_mapped_init` now returns an `int` instead of `bool`. - Raise a `rb_syserr_fail` error with the filepath and errno return code from `pm_string_mapped_init`. - Update `file_options` to return `static void` instead of `static bool`. - No longer return `Qnil` if `file_options` returns false (because now it will raise). - Add tests for `dump_file`, `lex_file`, `parse_file`, `parse_file_comments`, `parse_lex_file`, and `parse_file_success?` when a file doesn't exist and for `nil`. - Updates the `bin/parse` script to no longer raise it's own `ArgumentError` now that we raise a proper error. - Updates the `ffi` backend to raise a `SystemCallError` with the `filepath` and return code from `pm_string_mapped_init`. Fixes: #2207 Note: I'll have a followup PR to do a similar thing for ruby/ruby in `pm_parse_file`, I just need a test.
- Loading branch information
1 parent
e97e5f8
commit a736bef
Showing
6 changed files
with
147 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters