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

Introduce erl_drv_command_error() #6859

Conversation

rickard-green
Copy link
Contributor

@rickard-green rickard-green commented Feb 14, 2023

  • int erl_drv_command_error(ErlDrvPort port, char *error_reason)

    Generate an error exception, with the reason error_reason as an atom, in a call to the erlang:port_command/2 BIF or the erlang:port_command/3 BIF. The error can only be generated from the drivers outputv() or output() callbacks, which implements port command, when the port command has been initiated via one of the synchronous port_command() BIFs. When the port command has been initiated by the asynchronous Port ! {Owner, {command, Data}} construct, this call will fail and no exception will be generated.

    error_reason needs to be a null terminated latin1 string. If the string is longer than 255 characters (excluding the null termination character), it will be truncated to 255 characters.

    Returns zero on success and a non-zero integer on failure.

@rickard-green rickard-green added team:VM Assigned to OTP team VM feature testing currently being tested, tag is used by OTP internal CI labels Feb 14, 2023
@rickard-green rickard-green added this to the OTP-25.3 milestone Feb 14, 2023
@rickard-green rickard-green self-assigned this Feb 14, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 14, 2023

CT Test Results

       3 files     125 suites   42m 43s ⏱️
1 503 tests 1 452 ✔️ 51 💤 0
1 815 runs  1 746 ✔️ 69 💤 0

Results for commit 68bad4d.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@rickard-green
Copy link
Contributor Author

@RaimoNiskanen for use when solving #6455

@rickard-green rickard-green force-pushed the rickard/port_command-errors/OTP-18464 branch 2 times, most recently from b79ce55 to 3bd8e1c Compare February 15, 2023 01:22
@rickard-green rickard-green removed the testing currently being tested, tag is used by OTP internal CI label Feb 15, 2023
@rickard-green rickard-green force-pushed the rickard/port_command-errors/OTP-18464 branch from 3bd8e1c to 68bad4d Compare February 15, 2023 01:57
@rickard-green rickard-green added the testing currently being tested, tag is used by OTP internal CI label Feb 15, 2023
@rickard-green rickard-green force-pushed the rickard/port_command-errors/OTP-18464 branch from 68bad4d to f845b31 Compare February 16, 2023 11:55
@sverker
Copy link
Contributor

sverker commented Feb 16, 2023

What about changing argument char* error_reason to ErlDrvTermData error_reason_atom to be created by existing driver_mk_atom(). Two advantages:

  • Avoid introducing Latin1 string in new API.
  • Can be used more efficient by calling driver_mk_atom() once at driver load time.

@rickard-green rickard-green removed the testing currently being tested, tag is used by OTP internal CI label Feb 16, 2023
@rickard-green
Copy link
Contributor Author

@RaimoNiskanen Closing this since it cannot be used in solving #6455. Looking into other alternatives...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants