Skip to content

EPUB.Writer.convert! returns error tuples instead of raising #19

Description

@StephanMeijer

Problem

DocSpec.Core.EPUB.Writer.convert!/1 and convert!/2 violate Elixir's bang function convention. Bang functions should raise on error and return bare values, but these return {:ok, binary()} | {:error, term()}:

@spec convert!(spec :: DocumentSpecification.t()) :: {:ok, binary()} | {:error, term()}

This surprises every Elixir developer who uses the library — calling convert! and getting back an ok/error tuple is a contract violation.

Expected behavior

Following Elixir convention:

  • convert/1{:ok, binary()} | {:error, term()}
  • convert!/1binary() (raises on error)

Files

  • lib/docspec/core/epub/writer.ex
  • lib/docspec/cli.ex (caller)

Notes

This is a breaking change for the public API. Recommend shipping with a major or minor version bump.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions