An enum with a from() that had to become tryFrom()

A backed enum hydrated from a database column, and a row written in 2019 with a value the enum does not have.

// what threw, in production, on one row
$status = OrderStatus::from($row['status']);
// ValueError: "awaiting_stock" is not a valid backing
// value for enum OrderStatus

// what it became
$status = OrderStatus::tryFrom($row['status'])
    ?? throw new UnknownStoredStatus($row['id'], $row['status']);

from() throwing is correct behaviour and the exception it throws is useless — it names the value and not the row. Wrapping it means the log line identifies which order to look at, which turned a twenty-minute investigation into a query. The underlying fix was a data migration for eleven rows and a CHECK constraint so it cannot recur.