Skip to content

Likes string parser throws unclear exception when no digits are found #60

@devanfibio

Description

@devanfibio

Description

The parsing of likes string does not handle edge cases properly. When Utils.removeNonDigitCharacters() returns null or an empty string, the code attempts to parse it with Integer.parseInt(), resulting in a NumberFormatException with a cryptic error message.

Expected Behavior

The parser should validate that the processed string contains digits before attempting to parse it. If no digits are found, it should throw a clear, descriptive ParsingException that explains what went wrong.

Actual Behavior

When a likes string contains no digits or when removeNonDigitCharacters() returns null, Integer.parseInt() throws a NumberFormatException with a generic error message that doesn't help users understand the actual problem.

Steps to Reproduce

  1. Process a likes string with no digits (e.g., "likes: N/A")
  2. Call the parsing method
  3. Result: NumberFormatException with unclear message
  4. Expected: ParsingException with message indicating no digits were found

Root Cause

The code lacks validation of the string returned by Utils.removeNonDigitCharacters() before passing it to Integer.parseInt().

Related

Resolved by PR #59

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions