pub struct PrintableErrno<S: AsRef<str>> { /* private fields */ }Expand description
This is the base struct containing basic error information. Unless
you call printable_error or you unwrap the error on a Result
containing a PrintableErrno, you probably won’t use this directly.
When printed, the error message will look like the following:
- If there is an associated errno:
$program_name: $message: ${errno.desc()} - If there is no errno (called from printable_error):
$program_name: $message
Printed error tries to follow perror(3p)’s format with the
addition of the program name.
Implementations§
Source§impl<S: AsRef<str>> PrintableErrno<S>
impl<S: AsRef<str>> PrintableErrno<S>
Sourcepub fn bail(self, exit_code: i32) -> ExitError<S>
pub fn bail(self, exit_code: i32) -> ExitError<S>
Attach an exit code to the Error. Useful for bubbling up errors from a deep
function using the ? operator.
Sourcepub fn eprint_signalsafe(&self)
pub fn eprint_signalsafe(&self)
Same as PrintableErrno::eprint, but attempts to write() directly to stderr
and not to call any non-signal-safe functions. Useful when one is the child
in a multi-threaded program after a call to fork().
§Note
No allocations should be made in this function in order to comply with fork()s
contract of signal-safety.
§Safety
The caller must ensure that stderr (fd 2) remains open for the entirety of this function call. A naive attempt at detecting a closed file descriptor is made on first write. However, any subsequent writes may silently fail if stderr is closed while this function is running.