19962009 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. erl_error Torbjörn Törnkvist Torbjörn Törnkvist Bjarne Däcker Torbjörn Törnkvist 961014 A erl_error.sgml
erl_error Error Print Routines

This module contains some error printing routines taken from Advanced Programming in the UNIX Environment by W. Richard Stevens.

These functions are all called in the same manner as , i.e. with a string containing format specifiers followed by a list of corresponding arguments. All output from these functions is to .

voiderl_err_msg(FormatStr, ... ) Non-fatal error, and not system call error const char *FormatStr;

The message provided by the caller is printed. This function is simply a wrapper for .

voiderl_err_quit(FormatStr, ... ) Fatal error, but not system call error const char *FormatStr;

Use this function when a fatal error has occurred that is not due to a system call. The message provided by the caller is printed and the process terminates with an exit value of 1. The function does not return.

voiderl_err_ret(FormatStr, ... ) Non-fatal system call error const char *FormatStr;

Use this function after a failed system call. The message provided by the caller is printed followed by a string describing the reason for failure.

voiderl_err_sys(FormatStr, ... ) Fatal system call error const char *FormatStr;

Use this function after a failed system call. The message provided by the caller is printed followed by a string describing the reason for failure, and the process terminates with an exit value of 1. The function does not return.

Error Reporting

Most functions in erl_interface report failures to the caller by returning some otherwise meaningless value (typically or a negative number). As this only tells you that things did not go well, you will have to examine the error code in if you want to find out more about the failure.

volatile interl_errno The variable contains the erl_interface error number. You can change the value if you wish.

is initially (at program startup) zero and is then set by many erl_interface functions on failure to a non-zero error code to indicate what kind of error it encountered. A successful function call might change (by calling some other function that fails), but no function will ever set it to zero. This means that you cannot use to see if a function call failed. Instead, each function reports failure in its own way (usually by returning a negative number or ), in which case you can examine for details.

uses the error codes defined in your system's ]]>.

Actually, is a "modifiable lvalue" (just like ISO C defines to be) rather than a variable. This means it might be implemented as a macro (expanding to, e.g., ). For reasons of thread- (or task-)safety, this is exactly what we do on most platforms.