⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@kamahen
Copy link
Member

@kamahen kamahen commented Jan 7, 2026

No description provided.

% hello :- write('hello hello hello')
with_output_to(string(Out), hello).

test(helloex, error(unknown_error('an exception'))) :-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors should always be of the shape error(Formal, Context). That is used everywhere in the system to distinguish error exceptions from other exceptions (like timeout, abort, etc.) Typically you leave the 2nd argument unbound in SWI-Prolog. The exception handler adds the context, either as a single predicate or as a stack trace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few other places where errors are of the wrong shape -- I'll review all the SWI-cpp2.* code and add another commit. This might break backwards compatibility, but I hope not.

If I can, I'll also make PlException's constructor inaccessible, to avoid making this mistake again.

@kamahen
Copy link
Member Author

kamahen commented Jan 12, 2026

I think I have a solution that helps avoid "wrong shape" error terms, but I need to think about it a bit more. If it seems to be good, I'll close this PR and create new PRs with the improvement.

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.

2 participants