LogicError
The error a program raises when the mistake is its own.
A base that does not exist, a depth outside the range a member allows, a unit too small to move the value it was handed: these are faults in the code, not in the world around it. Novis gives them their own half of the exception tree, so a program can tell we got this wrong from something outside said no without reading the message and guessing.
Catching one is usually the wrong instinct: the honest answer to a bug is to fix the call. Work that has to finish anyway is the exception, and it records the fault as its own.
Good to know: it sits beside RuntimeError under Throwable rather than under it, so a clause written for runtime errors never takes one, and neither half contains the other.
The examples below show a call the library refuses, the two clauses that tell our fault from the world's, and a report that finishes and names the rows whose settings were wrong.
Examples
A call the library refuses
<?nvs// The plainest way to meet this error: a call the program itself got wrong.// Adding days to a date moves it. Adding hours to one does not mean anything,// so the member refuses rather than guessing, and says which call it was.
var $released = Core\Time\Date::at(2026, 4, 1);
echo $released->plus(30, Core\Unit::Day)->format('yyyy-MM-dd'), "\n";
try { echo $released->plus(30, Core\Unit::Hour)->format('yyyy-MM-dd'), "\n";} catch (LogicError $ourMistake) { echo $ourMistake->message, "\n";}2026-05-01Core\Time\Date::plus(): a unit smaller than `Unit::Day` does not move a dateOur fault or the worlds
<?nvs// Which clause a failure lands in is the whole reason the tree splits where it// does. A depth the program picked badly is ours to fix. A document that// arrived broken is not, and it is handled rather than fixed. Telling the two// apart by reading the message would be a guess.
final class Report{ public static function rowsIn(string $document, uint $depth): tainted string { try { var $rows = Core\Json::decode($document, { maxDepth: $depth }); return 'read'; } catch (LogicError $ourBug) { return 'our bug: ' . $ourBug->message; } catch (RuntimeError $badInput) { return 'bad input: ' . $badInput->message; } }}
echo Report::rowsIn('[1, 2, 3]', 32), "\n";echo Report::rowsIn('[1, 2, 3]', 0), "\n";echo Report::rowsIn('[1, 2,', 32), "\n";readour bug: Core\Json::decode(): a `maxDepth` of 0 is outside 1..=1024bad input: Core\Json::decode(): EOF while parsing a value at line 1 column 6A nightly report that finishes
<?nvs// A nightly run prints a reference number for each customer, in the base from their settings.// One setting has base 40. A base must be 2 to 36, so `format` throws a `LogicError`.// The run catches it, counts that row as a setting to fix, and prints the other rows.
final class Nightly{ public static function reference(int $order, uint $base): string { return Core\BigInt::of($order)->format({ radix: $base }); }
// The code is built before the line is printed. A row that throws prints // only the "skipped" line. public static function run(array<string> $customers, array<uint> $bases, array<int> $orders): uint { uint $toFix = 0; uint $row = 0; while ($row < 3) { try { string $code = Nightly::reference($orders[$row], $bases[$row]); echo $customers[$row], ': ', $code, "\n"; } catch (LogicError $badSetting) { echo $customers[$row], ': skipped, ', $badSetting->message, "\n"; $toFix = $toFix + 1; } $row = $row + 1; } return $toFix; }}
array<string> $customers = ['Ferngrove', 'Hallbeck', 'Ostrander'];array<uint> $bases = [16, 40, 36];array<int> $orders = [4021, 1204, 9000000];
uint $toFix = Nightly::run($customers, $bases, $orders);echo 'settings to fix: ', $toFix, "\n";Ferngrove: fb5Hallbeck: skipped, Core\BigInt::format(): radix 40 is outside the 2 to 36 this class reads and writesOstrander: 5cwg0settings to fix: 1