# `Localize.ParseError`
[🔗](https://github.com/elixir-localize/localize/blob/v0.25.0/lib/localize/exception/parse_error.ex#L1)

Exception raised when a language tag, unit identifier, or MF2 message
cannot be parsed.

For MF2 message parse errors, the exception carries structured source
location information (`:offset`, `:line`, `:column`) describing where
in the input the parser failed. `:line` and `:column` are 1-indexed
and `:offset` is a 0-indexed byte offset into the input string. This
information is intended for tooling — editor integrations, language
servers, and CLI diagnostics — that need to map errors back to source
positions.

For other uses (language tag / unit identifier parsing) the location
fields may be `nil`.

# `t`

```elixir
@type t() :: %Localize.ParseError{
  __exception__: true,
  column: pos_integer() | nil,
  input: String.t() | nil,
  line: pos_integer() | nil,
  offset: non_neg_integer() | nil,
  reason: String.t() | nil,
  rest: String.t() | nil
}
```

# `line_column`

```elixir
@spec line_column(String.t(), non_neg_integer()) :: {pos_integer(), pos_integer()}
```

Computes 1-indexed line and column for a byte offset into `input`.

### Arguments

* `input` is the source string.

* `offset` is a 0-indexed byte offset into `input`.

### Returns

* `{line, column}` where both are 1-indexed positive integers.

* If `offset` is out of bounds, returns the position of the last
  character (or `{1, 1}` for an empty input).

### Examples

    iex> Localize.ParseError.line_column("Hello\nworld", 0)
    {1, 1}

    iex> Localize.ParseError.line_column("Hello\nworld", 6)
    {2, 1}

    iex> Localize.ParseError.line_column("Hello\nworld", 9)
    {2, 4}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
