Libft
Custom implementation of core libc functions with additional utility helpers.
Loading...
Searching...
No Matches
Error Functions

Error reporting utilities. More...

Functions

void print_err (bool print_errno, const char *message)
 Prints "Error\n" to stderr with optional message and errno.
 
void fprint_err (bool print_errno, const char *safe, const char *fmt,...)
 Prints "Error\n" to stderr with safe prefix + formatted suffix.
 

Detailed Description

Error reporting utilities.

Functions to print formatted error messages to stderr.

Function Documentation

◆ fprint_err()

void fprint_err ( bool  print_errno,
const char *  safe,
const char *  fmt,
  ... 
)

Prints "Error\n" to stderr with safe prefix + formatted suffix.

Prints safe prefix always, then attempts to format and append fmt. If formatting fails, only the safe prefix is printed. '
' is always printed at the end.

Warning
safe and fmt must NOT be NULL, use print_err() otherwise.
Parameters
print_errnoIf true, prints errno description using strerror().
safeSafe prefix printed unconditionally (borrowed).
fmtFormat string for suffix (borrowed).
...Variadic arguments for format specifiers.
Here is the call graph for this function:

◆ print_err()

void print_err ( bool  print_errno,
const char *  message 
)

Prints "Error\n" to stderr with optional message and errno.

If print_errno is false and message is NULL, only "Error\n" is printed. If print_errno is true, uses strerror() to print the errno description. If message is not NULL, prints the message. '
' is always printed at the end.

Parameters
print_errnoIf true, prints errno description using strerror().
messageOptional message to print (borrowed, can be NULL).
Here is the call graph for this function: