1.\" Copyright (c) 1993 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)err.3 5.1 (Berkeley) 03/04/93 7.\" 8.Dd "" 9.Dt ERR 3 10.Os BSD 4 11.Sh NAME 12.Nm err , 13.Nm verr , 14.Nm errx , 15.Nm verrx , 16.Nm warn , 17.Nm vwarn , 18.Nm warnx , 19.Nm vwarnx 20.Nd formatted error messages 21.Sh SYNOPSIS 22.Fd #include <err.h> 23.Ft void 24.Fn err "int eval" "const char *fmt" "..." 25.Ft void 26.Fn verr "int eval" "const char *fmt" "va_list args" 27.Ft void 28.Fn errx "int eval" "const char *fmt" "..." 29.Ft void 30.Fn verrx "int eval" "const char *fmt" "va_list args" 31.Ft void 32.Fn warn "const char *fmt" "..." 33.Ft void 34.Fn vwarn "const char *fmt" "va_list args" 35.Ft void 36.Fn warnx "const char *fmt" "..." 37.Ft void 38.Fn vwarnx "const char *fmt" "va_list args" 39.Sh DESCRIPTION 40The 41.Fn err 42and 43.Fn warn 44family of functions display a formatted error message on the standard 45error output. 46In all cases, the error message is preceded by the last component 47of the program name, a colon character, and a space. 48In the case of the 49.Fn err , 50.Fn verr , 51.Fn warn , 52and 53.Fn vwarn 54functions, a colon character, a space and the error message string 55affiliated with the current value of the global variable 56.Va errno 57are displayed after the formatted error message. 58In all cases, the message is followed by a newline character. 59.Pp 60The 61.Fn err , 62.Fn verr , 63.Fn errx , 64and 65.Fn verrx 66functions do not return, but exit with the value of the argument 67.Fa eval . 68.Sh EXAMPLES 69Display the current errno information string and exit: 70.Bd -literal -offset indent 71if ((fd = open(file_name, O_RDONLY, 0)) == -1) 72 err(1, "%s", file_name); 73.Ed 74.Pp 75Display an error message and exit: 76.Bd -literal -offset indent 77if (tm.tm_hour < START_TIME) 78 errx(1, "too early, wait until %s", start_time_string); 79.Ed 80.Pp 81Warn of an error: 82.Bd -literal -offset indent 83if ((fd = open(raw_device, O_RDONLY, 0)) == -1) 84 warnx("%s: %s: trying the block device", 85 raw_device, strerror(errno)); 86if ((fd = open(block_device, O_RDONLY, 0)) == -1) 87 err(1, "%s", block_device); 88.Ed 89.Sh SEE ALSO 90.Xr strerror 3 91.Sh HISTORY 92The 93.Fn err 94and 95.Fn warn 96functions are 97.Ud . 98