8000 Handles exception for corrupted unexpected stdin by mattr64 · Pull Request #625 · pagermon/pagermon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Handles exception for corrupted unexpected stdin #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mattr64
Copy link
@mattr64 mattr64 commented Dec 29, 2024

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Validation of Regex Matches:

Before accessing capture groups, the script checks if the match was successful and if the expected groups are present.
This prevents attempting to read properties from null which was causing exception if input was unexpected.

Error Handling:

Wrapped the entire line processing logic inside a try-catch block.
Errors are logged with the problematic line for easier debugging to look at what unexpected input is received. 

Logging Enhancements:

Detailed error messages include the line content that caused the issue, aids in identifying patterns or unexpected formats in the input data.

Regex Patterns as Constants:

Defined regex patterns as constants at the top for better organization, this can help if new scenarios need handling.

Use of process.exit(0) Instead of return:

In Node.js, return at the top level doesn't stop the script. Using process.exit(0) ensures the script exits after creating the config file.

Rearranged padDigits to use a built in function: String.prototype.padStart

Strict Mode - enabled this during debugging to catch the exceptions / any unhandled inputs, so I left it enabled.

Type of change

Please delete options that are not relevant.

  • [ X] Bug fix (non-breaking change which fixes an issue)
  • [ X] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [X ] Ran rtl_fm raw input into stdin for days, no crashes seen. Previously I was getting crashes every few seconds if signal strength was low (meaning input was often corrupt or did not contain a message)

Checklist:

  • My code follows the style guidelines of this project
  • [X ] I have performed a self-review of my own code
  • [X ] I have commented my code, particularly in hard-to-understand areas
  • I have updated changelog.md with changes made << Unsure here on format, appreciate some guidance :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0