'\"macro stdmacro
.if n .pH g3n.t_error @(#)t_error	40.4 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} t_error 3N "Networking Support Utilities" "\&"
.if \nX=1 .ds x} t_error 3N "Networking Support Utilities"
.if \nX=2 .ds x} t_error 3N "" "\&"
.if \nX=3 .ds x} t_error "" "" "\&"
.if \nX=4 .ds x} t_error "NS_LIB" "EXTENSION" " "
.TH \*(x}
.SH NAME
\f4t_error\f1 \- produce error message
.SH SYNOPSIS
\f4#include <tiuser.h>\f1
.PP
\f4void t_error(errmsg)\f1
.br
\f4char *errmsg;\f1
.br
\f4extern int t_errno;\f1
.br
\f4extern char *t_errlist[];\f1
.br
\f4extern int t_nerr;\f1
.SH DESCRIPTION
\f4t_error\fP
produces a message on the standard error output
which describes the last error encountered during a call to a transport function.
The argument string \f4errmsg\fP is a user-supplied error message that
gives context to the error.
.P
\f4t_error\fP prints the user-supplied error message followed by a colon and
the standard transport function error message for the current value
contained in \f4t_errno\fP.
If \f4t_errno\fP is \f4TSYSERR\fP, \f4t_error\fP
will also print the standard error message for the current value contained
in \f4errno\f1 [see \f4intro\fP(2)].
.P
\f4t_errlist\fP is the array of message strings, to allow user message
formatting.
\f4t_errno\fP can be used as an index into this array to retrieve the
error message string (without a terminating newline).
\f4t_nerr\fP is the maximum index value for the \f4t_errlist\fP array.
.PP
\f4t_errno\fP is set when an error occurs and is not cleared on
subsequent successful calls.
.SH EXAMPLE
If a \f4t_connect\fP function fails on transport endpoint
\f4fd2\f1 because a bad address was given, the following call
might follow the failure:
.PP
.RS
t_error("t_connect failed on fd2");
.RE
.PP
The diagnostic message would print as:
.PP
.RS
t_connect failed on fd2:  Incorrect transport address format
.RE
.PP
where ``t_connect failed on fd2'' tells the user which function failed
on which transport endpoint, and ``Incorrect transport address format''
identifies the specific error that occurred.
.SH SEE ALSO
\f2UNIX System V Network Programmer's Guide\f1.
.Ee
