Skip to content

bug: EAN encoder throws plain Error instead of InvalidInputError #66

@productdevbook

Description

@productdevbook

Summary

The EAN encoder in src/encoders/ean.ts throws plain Error instead of InvalidInputError from the project's error classes, inconsistent with all other encoders.

Details

// ean.ts line 87
throw new Error("EAN-13 requires 12 or 13 digits");
// ean.ts line 150
throw new Error("EAN-8 requires 7 or 8 digits");

Every other encoder in the project uses:

import { InvalidInputError } from "../errors";
throw new InvalidInputError("...");

Impact

  • Users catching InvalidInputError will miss EAN validation errors
  • Inconsistent error handling behavior across the library

Fix

Import InvalidInputError and replace both throw new Error(...) calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions