Skip to content

fix: raise AnalyzerError when an analyzer fails to load - #49

Merged
ddehilster merged 2 commits into
VisualText:mainfrom
ddehilster:fix/raise-on-build-failure
Oct 29, 2026
Merged

ddehilster merged 2 commits into
VisualText:mainfrom
ddehilster:fix/raise-on-build-failure

Conversation

@ddehilster

@ddehilster ddehilster commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

analyze() and compile() returned normally when the analyzer was missing, its KB did not load, or a pass did not build. The engine returned -1 and said why only on its own stderr, which Python cannot capture on Windows. Callers got "" back and had to guess a build failure from every output coming back empty.

Change

  • bindings.cpp: analyze and compile throw RuntimeError when the engine returns a negative value. Direct users of NLP_ENGINE no longer get a silent "".
  • Engine.analyze() / Engine.compile() raise NLPPlus.AnalyzerError. Like AnalysisStopped, it is both an EngineException and an Exception.
    • .log holds the logs/make_ana.log and logs/cgerr.log that the failed call wrote. Logs left by earlier runs are ignored.
    • The message repeats the lines that are not routine:
AnalyzerError: analyzer broken failed to load:
  2 2 [Syntax error.]
  2 0 [Nintern: No semantics for parse tree.]
  ...

Related: VisualText/nlp-engine#815 (4.2.52, merged)

That PR makes a .kbb with CRLF line endings load on Linux and macOS. test_crlf_kbb_loads skips on engines before 4.2.52 and starts running once the submodule bump to 4.2.52 lands. Nothing else here depends on it: logs/make_ana.log is already written on Linux at 4.2.51, so AnalyzerError carries the build errors there today.

Testing

Ran the full suite on wheels built with engine 4.2.51 plus nlp-engine#815:

  • Windows: 28/28 passed.
  • Linux (WSL, Ubuntu 24.04): 26 passed, 2 skipped (the Windows-only locale tests).

🤖 Generated with Claude Code

ddehilster and others added 2 commits October 29, 2026 15:56
analyze() and compile() returned normally when the analyzer was missing,
its KB did not load, or a pass did not build. The engine returned -1 and
said why only on its own stderr, which Python cannot capture on Windows,
so callers got "" back and had to guess a build failure from every
output coming back empty.

The binding now throws on a negative return from the engine, and Engine
raises NLPPlus.AnalyzerError (an EngineException and an Exception, like
AnalysisStopped). It carries the logs/make_ana.log and logs/cgerr.log
that the failed call wrote, and its message repeats the lines that are
not routine, eg "2 2 [Syntax error.]" for pass 2, line 2.

tests/test_load_errors.py also covers two engine fixes in nlp-engine
4.2.52: logs/ is made on Linux and macOS, and a CRLF .kbb loads there.
test_logs_are_written and test_crlf_kbb_loads fail on Linux until the
submodule is bumped to that release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The package still pins engine 4.2.51, which kept the '\r' of every .kbb
line on Linux, so the test failed CI there. It runs again once the
submodule bump to 4.2.52 lands. test_logs_are_written already passes on
4.2.51: the docstring no longer says it needs the engine fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ddehilster
ddehilster merged commit 657f576 into VisualText:main Oct 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant