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 callingException::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 assigns0toFBB::g_errno(see the next constructor, it explains things).Exception(int errnoValue)β this constructor stores the providederrnoValuevalue in a thread-local variableint FBB::g_errno. okay so history lesson: before Bobcat 4.04.00,errnoValuewas only stored in the global::errnovariable (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. π thethread_local int FBB::g_errnovariable 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 theFBB::Exceptionobject. 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 anostringstreamobject. 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 openStreamType>stream object which can be used to move-construct aStreamTypeobject. e.g.
auto out{ Exception::factory<ofstream>("/tmp/out") };
static StreamType factory<StreamType>(int errnoValue, std::string const &name)β returns an openStreamType>stream object which can be used to move-construct aStreamTypeobject. if constructing the stream object fails, then the thrownFBB::ExceptionassignserrnoValuetoFBB::g_errno.static StreamType factory<StreamType>(std::string const &name, std::ios::openmode mode)β returns an openStreamType>stream object, created using theopenmodemodeflags, which can be used to move-construct aStreamTypeobject.static StreamType factory<StreamType>(int errnoValue, std::string const &name, std::ios::openmode mode)β returns an openStreamType>stream object, created using theopenmodemodeflags, which can be used to move-construct aStreamTypeobject. if constructing the stream object fails, then the thrownFBB::ExceptionassignserrnoValuetoFBB::g_errno.static StreamType factory<StreamType>(std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2)β returns an openStreamType>stream object. the stream is initially opened usingmode1. if that fails,mode2is used. if both ways to open the stream fail, then anExceptionis thrown. the returned stream can be used to move-construct aStreamTypeobject. this member can be used to open anstd::fstreamwhich 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 openStreamType>stream object. the stream is initially opened usingmode1. if that fails,mode2is used. if both ways to open the stream fail, then anExceptionis thrown, assigningerrnoValuetoFBB::g_errno.static void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode)β opens the stream object, using itsopenmember, passingmodetoopen. if opening the stream fails, then the thrownFBB::ExceptionassignserrnoValuetoFBB::g_errno.static void open(StreamType &stream, std::string const &name)β opens the stream object, using its defaultopenmember.static void open(int errnoValue, StreamType &stream, std::string const &name)β opens the stream object, using its defaultopenmember. if opening the stream fails, then the thrownFBB::ExceptionassignserrnoValuetoFBB::g_errno.static void open(StreamType &stream, std::string const &name, std::ios::openmode mode)β opens the stream object, using itsopenmember, passingmodetoopen.static void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode)β opens the stream object, using itsopenmember, passingmodetoopen. if opening the stream fails, then the thrownFBB::ExceptionassignserrnoValuetoFBB::g_errno.static void open(StreamType &stream, std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2)β opens the stream object, using itsopenmember,, initially passingmode1toopen. if that fails,mode2is used. if both ways to open the stream fail, then anExceptionis 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 itsopenmember, initially passingmode1toopen. if that fails,mode2is used. if both ways to open the stream fail, then anExceptionis thrown, assigningerrnoValuetoFBB::g_errno.static size_t protection(std::string const &path, size_t protect, Protection type = EQUAL)β returns the protection bits (cf.open(2)) ofpath. theprotectparameter is used to specify the requested protection bits, and it's usually specified as an octal value. if the specified value exceeds0777, 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.
ifpathis created byprotection, then opening a stream forpathdoes not changepath'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 currenterrnovalue is inserted into theFBB::Exceptionobject (it can also be used to insert the descriptive text in astd::ostreamobject). no text is inserted iferrnoequals zero. this manipulator is thread-safe (buterrnomay be modified whenerrnoholds 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 β
- https://fbb-git.gitlab.io/bobcat/ : gitlab project page;
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. π
π COPYRIGHT π
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
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms