FBB::Exception(3bobcat)

πŸ’– FBB::Exception β€” the insertable exception class πŸ’–

okay bestie, welcome to the FBB::Exception(3bobcat) page, aka the glow-up your std::exception has been waiting for. this is FBB::Exception from the bobcat crew, and it's giving "exception but make it cute and chatty" ✨

πŸŽ€ NAME πŸŽ€

FBB::Exception β€” it's a std::exception object that accepts stream insertions, no cap. like, you can literally << your feelings into it. iconic.

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <bobcat/exception>
Linking option: -lbobcat

🌸 DESCRIPTION 🌸

so here's the tea: FBB::Exception objects are derived from std::exception, but they accept stream insertions. that's the whole vibe. πŸ’…

the intended use is throwing an anonymous object, and into that object you've inserted the text of the std::exception::what message. throw + tell the story at the same time. periodt.

these Exception exceptions get thrown by a lot of Bobcat classes. the girlies are: Arg, ArgConfig, BigInt, Cgi, Cidr, ClientSocket, CmdFinderBase, ConfigFile, DateTime, DecryptBuf, DigestBuf, EncryptBuf, Fork, GetHostent, Glob, HMacBuf, Hostname, LocalClientSocket, LocalServerSocket, LocalSocketBase, Log, MailHeaders, Mbuf, Milter, Mstream, OFoldBuf, OneKey, Pattern, Pipe, Process, Redirector, Selector, ServerSocket, Signal, SocketBase, Stat, TempStream, User, Xpointer.

like… the whole squad throws Exception. it's THE main character of error handling, iykyk. πŸ‘‘


πŸ’œ NAMESPACE πŸ’œ

FBB

every single constructor, member, operator and manipulator mentioned on this man-page is defined in the namespace FBB. don't go looking for them anywhere else, bestie.

🧚 INHERITS FROM 🧚

std::exception

🌈 ENUMERATION 🌈

the enumeration Protection is used by the member protection (described below, keep scrolling πŸ‘€). it has two values:

  • ANY: an existing file may have any set of protection bits;
  • EQUAL: an existing file mut have exactly the set of protection bits as specified when calling Exception::protection.

(and yes, "mut" is what the original says. we're keeping it, it's part of the lore 🫢)


✨ CONSTRUCTORS ✨

  • Exception() β€” the default constructor. it assigns 0 to FBB::g_errno (see the next constructor, it explains things).
  • Exception(int errnoValue) β€” this constructor stores the provided errnoValue value in a thread-local variable int FBB::g_errno. okay so history lesson: before Bobcat 4.04.00, errnoValue was only stored in the global ::errno variable (it still is, ngl), but since that variable is also used by so many other functions, errno's value may have already changed by the time the exception gets caught. 😭 the thread_local int FBB::g_errno variable does not have that drawback. slay.

when g_errno must be declared without including bobcat/exception, then do this:

namespace FBB
{
    extern thread_local int g_errno;
}

copy and move constructors (and assignment operators) are available. yes, all of them. 🫢

πŸ‘‘ MEMBER FUNCTIONS πŸ‘‘

all members of std::exception are available, since FBB::Exception inherits from that class. so you get the whole family tree.

  • char const *what() const noexcept(true) override β€” returns the text that was inserted into the FBB::Exception object. it's basically the exception telling you what went down. πŸ’…

πŸ”₯ OVERLOADED OPERATORS πŸ”₯

  • Exception &&operator<<(Exception &&in, Type const &t) β€” a function template implementing the overloaded insertion operator. it can be used to insert values of any type that can also be inserted into an ostringstream object. any type, bestie. that's the range.

πŸ“ STATIC MEMBERS πŸ“

these convenience functions are for controlled opening of stream-type objects, like std::ofstream and std::ifstream objects. those stream-type objects have to support open and close members, like the ones std::ifstream and std::ofstream provide.

if the stream was already open, it is first closed. πŸ‘‹
if opening fails, an FBB::Exception exception is thrown containing a short message stating that the named stream could not be opened. πŸ’€
  • static StreamType factory<StreamType>(std::string const &name) β€” returns an open StreamType> stream object which can be used to move-construct a StreamType object. e.g.
auto out{ Exception::factory<ofstream>("/tmp/out") };
  • static StreamType factory<StreamType>(int errnoValue, std::string const &name) β€” returns an open StreamType> stream object which can be used to move-construct a StreamType object. if constructing the stream object fails, then the thrown FBB::Exception assigns errnoValue to FBB::g_errno.
  • static StreamType factory<StreamType>(std::string const &name, std::ios::openmode mode) β€” returns an open StreamType> stream object, created using the openmode mode flags, which can be used to move-construct a StreamType object.
  • static StreamType factory<StreamType>(int errnoValue, std::string const &name, std::ios::openmode mode) β€” returns an open StreamType> stream object, created using the openmode mode flags, which can be used to move-construct a StreamType object. if constructing the stream object fails, then the thrown FBB::Exception assigns errnoValue to FBB::g_errno.
  • static StreamType factory<StreamType>(std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2) β€” returns an open StreamType> stream object. the stream is initially opened using mode1. if that fails, mode2 is used. if both ways to open the stream fail, then an Exception is thrown. the returned stream can be used to move-construct a StreamType object. this member can be used to open an std::fstream which may or may not yet exist for both reading and writing. e.g.,
auto out{ Exception::factory<fstream>("/tmp/out",
            ios::in | ios::out,
            ios::in | ios::out | ios::trunc) };

if /tmp/out already exists, then ios::in | ios::out should succeed. if it doesn't, then it's created empty for reading and writing, using ios::in | ios::out | ios::trunc. πŸŽ€

  • static StreamType factory<StreamType>(int errnoValue, std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2) β€” returns an open StreamType> stream object. the stream is initially opened using mode1. if that fails, mode2 is used. if both ways to open the stream fail, then an Exception is thrown, assigning errnoValue to FBB::g_errno.
  • static void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode) β€” opens the stream object, using its open member, passing mode to open. if opening the stream fails, then the thrown FBB::Exception assigns errnoValue to FBB::g_errno.
  • static void open(StreamType &stream, std::string const &name) β€” opens the stream object, using its default open member.
  • static void open(int errnoValue, StreamType &stream, std::string const &name) β€” opens the stream object, using its default open member. if opening the stream fails, then the thrown FBB::Exception assigns errnoValue to FBB::g_errno.
  • static void open(StreamType &stream, std::string const &name, std::ios::openmode mode) β€” opens the stream object, using its open member, passing mode to open.
  • static void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode) β€” opens the stream object, using its open member, passing mode to open. if opening the stream fails, then the thrown FBB::Exception assigns errnoValue to FBB::g_errno.
  • static void open(StreamType &stream, std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2) β€” opens the stream object, using its open member,, initially passing mode1 to open. if that fails, mode2 is used. if both ways to open the stream fail, then an Exception is thrown.
  • static void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2) β€” opens the stream object, using its open member, initially passing mode1 to open. if that fails, mode2 is used. if both ways to open the stream fail, then an Exception is thrown, assigning errnoValue to FBB::g_errno.
  • static size_t protection(std::string const &path, size_t protect, Protection type = EQUAL) β€” returns the protection bits (cf. open(2)) of path. the protect parameter is used to specify the requested protection bits, and it's usually specified as an octal value. if the specified value exceeds 0777, an exception is thrown. 🚨

the third parameter is only used in combination with already existing files. if specified as ANY the file's actual permission bits are not compared with protect; if specified as EQUAL the file's permission bits must be identical to protect, or an exception is thrown.

if path does not yet exist, a file path with permission protect is created. this member returns path's permission bits.

if path is created by protection, then opening a stream for path does not change path's protection. noted, bestie. 🫢

πŸŽ€ MANIPULATOR πŸŽ€

the following manipulator is not part of the FBB::Exception class, but it is defined in the FBB namespace, and it can be inserted into the FBB::Exception object:

  • FBB::errnodescr β€” the descriptive text associated with the current errno value is inserted into the FBB::Exception object (it can also be used to insert the descriptive text in a std::ostream object). no text is inserted if errno equals zero. this manipulator is thread-safe (but errno may be modified when errno holds an invalid value). πŸ’€ careful out there.

πŸ’œ EXAMPLE πŸ’œ

if (exceptionalCondition)
    throw FBB::Exception{ 1 } << "Exceptional condition occurred";

look at that. throwing AND talking. main character energy fr fr. πŸ”₯

🌸 FILES 🌸

  • bobcat/exception β€” defines the class interface

πŸ¦‹ SEE ALSO πŸ¦‹

πŸ™ˆ BUGS πŸ™ˆ

None Reported.

⭐ BOBCAT PROJECT FILES ⭐

Debian Bobcat project files:

  • libbobcat6: debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;

πŸ‘‘ BOBCAT πŸ‘‘

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. cute AND informative. πŸ’…

This is free software, distributed under the terms of the GNU General Public License (GPL).

🫢 AUTHOR 🫢

Frank B. Brokken (f.b.brokken@rug.nl).


and that's the whole page, bestie!! πŸ’– this was FBB::Exception(3bobcat) from the libbobcat-dev_6.15.01 era, dated 2005-2026. go forth and throw insertable exceptions, you absolute icon. mwah. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from