mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:00:11 +01:00
Improved Error Handling in remap_file Function and Added .DS_Store to `.gitignore (#3195)
### Description: This pull request introduces two significant changes: **Improved Error Handling in `remap_file` Function:** - The error handling in the `remap_file` function has been simplified for improved clarity and user-friendliness. The original code included a combination of `assert` and `exit`, which could be perplexing during runtime. **Changes Made:** - Replaced the original `assert` and `exit` with a more straightforward `if-else` block for handling errors. - Utilized `sys.exit` for clear error messages and proper program termination when an error occurs. **Why I Did It:** - Improved Clarity: The original code's `assert` primarily served debugging purposes and might not behave as expected during runtime. The new code offers clarity and predictability. - User-Friendly Errors: The updated code provides users with easily understandable error messages. **Added `.DS_Store` to `.gitignore`:** - `.DS_Store` files are commonly generated by macOS Finder to store folder-specific metadata. They do not need to be tracked in version control. **Changes Made:** - Added `.DS_Store` to the `.gitignore` file. **Why I Did It:** - To prevent `.DS_Store` files from being tracked in the Git repository, ensuring a cleaner repository and avoiding unintended commits of macOS-specific files. ### Improvements: - **Better Error Handling:** The new code in the `remap_file` function ensures the program exits gracefully with informative error messages when errors occur. - **Enhanced Code Clarity:** The code now communicates its intentions more clearly with `sys.exit` for handling expected runtime errors. - **Cleaner Git Repository:** The addition of `.DS_Store` to `.gitignore` prevents the tracking of macOS-specific files in version control.
This commit is contained in:
@@ -33,3 +33,6 @@ compile_commands.json
|
||||
|
||||
# generated by utils/treesitter/helix.sh
|
||||
/.helix/
|
||||
|
||||
# Ignore .DS_Store files
|
||||
.DS_Store
|
||||
|
||||
@@ -96,7 +96,6 @@ def remap_file(label: str) -> str:
|
||||
return path.replace(":", "/")
|
||||
assert repo in EXTERNAL_REPOS, repo
|
||||
return EXTERNAL_REPOS[repo].remap(path)
|
||||
exit(f"Don't know how to remap label '{label}'")
|
||||
|
||||
|
||||
def get_bazel_list(list_child: ElementTree.Element, is_file: bool) -> Set[str]:
|
||||
|
||||
Reference in New Issue
Block a user