2 * Copyright (c) 2011, 2012, 2013 Spectra Logic Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * substantially similar to the "NO WARRANTY" disclaimer below
13 * ("Disclaimer") and any redistribution must be conditioned upon
14 * including a substantially similar Disclaimer requirement for further
15 * binary redistribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGES.
30 * Authors: Justin T. Gibbs (Spectra Logic Corporation)
36 * \file zfsd_exception.h
38 * Definition of the ZfsdException class hierarchy. All exceptions
39 * explicitly thrown by Zfsd are defined here.
41 #ifndef _DEVDCTL_EXCEPTION_H_
42 #define _DEVDCTL_EXCEPTION_H_
44 /*============================ Namespace Control =============================*/
48 /*============================= Class Definitions ============================*/
50 /*--------------------------------- Exception --------------------------------*/
52 * \brief Class allowing unified reporting/logging of exceptional events.
58 * \brief Exception constructor allowing arbitrary string
59 * data to be reported.
61 * \param fmt Printf-like string format specifier.
63 Exception(const char *fmt, ...);
66 * \brief Augment/Modify a Exception's string data.
68 std::string& GetString();
71 * \brief Emit exception data to syslog(3).
73 virtual void Log() const;
79 * \brief Convert exception string format and arguments provided
80 * in event constructors into a linear string.
82 void FormatLog(const char *fmt, va_list ap);
88 Exception::GetString()
93 /*------------------------------ ParseException ------------------------------*/
95 * Exception thrown when an event string is not converted to an actionable
98 class ParseException : public Exception
103 /** Improperly formatted event string encountered. */
106 /** No handlers for this event type. */
107 DISCARDED_EVENT_TYPE,
109 /** Unhandled event type. */
116 * \param type The type of this exception.
117 * \param parsedBuffer The parsing buffer active at the time of
119 * \param offset The location in the parse buffer where this
120 * exception occurred.
122 ParseException(Type type, const std::string &parsedBuffer,
128 * \return The classification for this exception.
130 Type GetType() const;
135 * \return The offset into the event string where this exception
138 size_t GetOffset() const;
141 /** The type of this exception. */
144 /** The parsing buffer that was active at the time of the exception. */
145 const std::string m_parsedBuffer;
148 * The offset into the event string buffer from where this
149 * exception was triggered.
154 //- ParseException Inline Const Public Methods ---------------------------------
155 inline ParseException::Type
156 ParseException::GetType() const
162 ParseException::GetOffset() const
167 } // namespace DevdCtl
168 #endif /* _DEVDCTL_EXCEPTION_H_ */