19962016 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. erl_error Torbjörn Törnkvist Torbjörn Törnkvist Bjarne Däcker Torbjörn Törnkvist 1996-10-14 A erl_error.xml
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 printf(), that is, with a string containing format specifiers followed by a list of corresponding arguments. All output from these functions is to stderr.

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 fprintf().

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 because of a system call. The message provided by the caller is printed and the process terminates with exit value 1. This 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 exit value 1. This function does not return.

Error Reporting

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

volatile interl_errno Variable erl_errno contains the Erl_Interface error number. You can change the value if you wish.

erl_errno 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 can change erl_errno (by calling some other function that fails), but no function does never set it to zero. This means that you cannot use erl_errno to see if a function call failed. Instead, each function reports failure in its own way (usually by returning a negative number or NULL), in which case you can examine erl_errno for details.

erl_errno uses the error codes defined in your system's <errno.h>.

erl_errno is a "modifiable lvalue" (just like ISO C defines errno to be) rather than a variable. This means it can be implemented as a macro (expanding to, for example, *_erl_errno()). For reasons of thread safety (or task safety), this is exactly what we do on most platforms.