Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling in READ_ALL_COMMANDS #4199

Closed
ThomasBreuer opened this issue Dec 11, 2020 · 2 comments
Closed

Error handling in READ_ALL_COMMANDS #4199

ThomasBreuer opened this issue Dec 11, 2020 · 2 comments
Labels
topic: libgap things related to libgap

Comments

@ThomasBreuer
Copy link
Contributor

LibGAP's GAP_EvalString calls the kernel function READ_ALL_COMMANDS, which does the same as the GAP function READ_ALL_COMMANDS.
Consider the following GAP session.

gap> READ_ALL_COMMANDS( InputTextString( "\"" ), false, true, ViewObj );
Syntax error: String must end with " before end of file in stream:1
[ [ false,,,, "" ] ]

The syntax error message is printed to the screen, a result is returned, and the false entry in the result indicates that an error happened.

When one uses the above input via LibGAP, what is the recommended way to handle the error in the code that calls GAP_EvalString, that is, access the error message (in order to report it) and then empty the buffer?
This error handling is currently missing in the GAP-Julia integration, see oscar-system/GAP.jl/issues/580.

@ThomasBreuer ThomasBreuer added the topic: libgap things related to libgap label Dec 11, 2020
@fingolfin
Copy link
Member

I think the idea was/is to set the ERROR_OUTPUT global in GAP to an output stream to which the error messages then are written. (That's not necessarily a great API, but it was the easiest to pull of on short notice back then.)

This is of course what reset_GAP_ERROR_OUTPUT does, so we can probably just use that / imitate what error_handler does?

ThomasBreuer added a commit to ThomasBreuer/GAP.jl that referenced this issue Jan 6, 2021
The right way to do this is to check the return value of `evalstr_ex`,
and to call `GAP.error_handler` if necessary,
as was proposed in the discussion of gap-system/gap/issues/4199.

This is intended to resolve issue oscar-system#580.

(The change does of course not affect the problems described in
issue oscar-system#596.)
@ThomasBreuer
Copy link
Contributor Author

Yes, calling error_handler in the function that calls GAP_EvalString solves the problem.

ThomasBreuer added a commit to oscar-system/GAP.jl that referenced this issue Jan 7, 2021
The right way to do this is to check the return value of `evalstr_ex`,
and to call `GAP.error_handler` if necessary,
as was proposed in the discussion of gap-system/gap/issues/4199.

This is intended to resolve issue #580.

(The change does of course not affect the problems described in
issue #596.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: libgap things related to libgap
Projects
None yet
Development

No branches or pull requests

2 participants