001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024:
025:
026:
027:
028:
029:
030:
031:
032:
033:
034:
035:
036:
037:
038:
039:
040:
041:
042:
043:
044:
045:
046:
047:
048:
049:
050:
051:
052:
053:
054:
055:
056:
057:
058:
059:
060:
061:
062:
063:
064:
065:
066:
067:
068:
069:
070:
071:
072:
073:
074:
075:
076:
077:
078:
079:
080:
081:
082:
083:
084:
085:
086:
087:
088:
089:
090:
091:
092:
093:
094:
095:
096:
097:
098:
099:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:




















































































































































































































































































































































































































































































/*
* Copyright (c), Zeriph Enterprises
* All rights reserved.
*
* Contributor(s):
* Zechariah Perez, omni (at) zeriph (dot) com
*
* THIS SOFTWARE IS PROVIDED BY ZERIPH AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL ZERIPH AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/* DEV_NOTE: this file is not intended to be used directly by any user code!

i.e. don't #include <omni/xxx_impl.hxx> and don't compile this source directly.
this file is #include'd directly in other source.

This file is specifically to contain the various exceptions the framework can throw
and is directly included in omni/exception.hpp so this file should not be included
in any other code, framework or user.
*/

// so as not to accidentally build this file with the source this macro defined in exception.hpp
#if !defined(OMNI_ERR_APPEND_FW)
    #error invalid preprocessor directive detected
#endif

namespace omni {
    namespace exceptions {
        class application_exception : public omni::exception
        {
            public:
                application_exception() : omni::exception(OMNI_ERR_APPEX_STR) {}
                application_exception(const char* msg, int er) : omni::exception(msg, er) {}
                application_exception(const char* msg, long er) : omni::exception(msg, er) {}
                explicit application_exception(const char* msg) : omni::exception(msg) {}
                explicit application_exception(int er) : omni::exception(OMNI_ERR_APPEX_STR, ": ", er) {}
                explicit application_exception(long er) : omni::exception(OMNI_ERR_APPEX_STR, ": ", er) {}
        };
        
        class environment_exception : public omni::exception
        {
            public:
                environment_exception() : omni::exception(OMNI_ERR_ENVEX_STR) {}
                explicit environment_exception(std::size_t err) : omni::exception(OMNI_ERR_ENVEX_STR, ": ", err) {}
                explicit environment_exception(const char* msg) : omni::exception(msg) {}
        };
        
        class mutex_system_exception : public omni::exception
        {
            public:
                mutex_system_exception() : omni::exception(OMNI_ERR_MUTEX_STR) {}
                explicit mutex_system_exception(int er) : omni::exception(OMNI_ERR_MUTEX_STR, ": ", er) {}
                explicit mutex_system_exception(long er) : omni::exception(OMNI_ERR_MUTEX_STR, ": ", er) {}
                explicit mutex_system_exception(const char* msg) : omni::exception(msg) {}
                mutex_system_exception(const char* msg, int er) : omni::exception(msg, er) {}
                mutex_system_exception(const char* msg, long er) : omni::exception(msg, er) {}
        };
        
        class semaphore_system_exception : public omni::exception
        {
            public:
                semaphore_system_exception() : omni::exception(OMNI_ERR_SEMAPHORE_STR) {}
                explicit semaphore_system_exception(int er) : omni::exception(OMNI_ERR_SEMAPHORE_STR, ": ", er) {}
                explicit semaphore_system_exception(long er) : omni::exception(OMNI_ERR_SEMAPHORE_STR, ": ", er) {}
                explicit semaphore_system_exception(const char* msg) : omni::exception(msg) {}
                semaphore_system_exception(const char* msg, int er) : omni::exception(msg, er) {}
                semaphore_system_exception(const char* msg, long er) : omni::exception(msg, er) {}
        };
        
        class string_exception : public omni::exception
        {
            public:
                string_exception() : omni::exception(OMNI_ERR_STROBJ_STR) {}
                explicit string_exception(const char* msg) : omni::exception(msg) {}
        };
        
        class thread_exception : public omni::exception
        {
            public:
                thread_exception() : omni::exception(OMNI_ERR_THREAD_STR) {}
                thread_exception(std::string msg, int perr) : omni::exception(msg, perr) {}
                thread_exception(std::string msg, std::size_t perr) : omni::exception(msg, perr) {}
                thread_exception(const char* msg, int perr) : omni::exception(msg, perr) {}
                thread_exception(const char* msg, std::size_t perr) : omni::exception(msg, perr) {}
                thread_exception(const char* msg, const char* extra, int perr) : omni::exception(msg, extra, perr) {}
                thread_exception(const char* msg, const char* extra, std::size_t perr) : omni::exception(msg, extra, perr) {}
                explicit thread_exception(const std::string& msg) : omni::exception(msg) {}
                explicit thread_exception(const char* msg) : omni::exception(msg) {}
                explicit thread_exception(int perr) : omni::exception(OMNI_ERR_THREAD_STR, ": ", perr) {}
                explicit thread_exception(std::size_t perr) : omni::exception(OMNI_ERR_THREAD_STR, ": ", perr) {}
        };
        
        class threadpool_exception : public omni::exception
        {
            public:
                threadpool_exception() : omni::exception(OMNI_ERR_THREADPOOL_STR) {}
                explicit threadpool_exception(const std::string& msg) : omni::exception(msg) {}
                explicit threadpool_exception(const char* msg) : omni::exception(msg) {}
        };
        
        class active_wait_exception : public omni::exception
        {
            public:
                active_wait_exception() : omni::exception(OMNI_ERR_WAIT_STR) {}
        };
        
        class clock_exception : public omni::exception
        {
            public:
                clock_exception() : omni::exception(OMNI_ERR_GET_TIME_STR) {}
                explicit clock_exception(int err) : omni::exception(OMNI_ERR_GET_TIME_STR, ": ", err) {}
        };
        
        class conditional_exception : public omni::exception
        {
            public:
                conditional_exception() : omni::exception(OMNI_ERR_COND_OBJ_STR) {}
                conditional_exception(int err) : omni::exception(OMNI_ERR_COND_OBJ_STR, ": ", err) {}
        };

        class nan_error : public omni::exception
        {
            public:
                nan_error() : omni::exception(OMNI_NAN_ERR_STR) {}
                explicit nan_error(const char* var) : omni::exception(OMNI_NAN_ERR_STR) {
                    if (var) {
                        this->m_what.append(": ");
                        this->m_what.append(var);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit nan_error(const std::string& var) : omni::exception(OMNI_NAN_ERR_STR) {
                    this->m_what.append(": ");
                    this->m_what.append(var);
                }
        };

        class overflow_error : public omni::exception
        {
            public:
                overflow_error() : omni::exception(OMNI_OVERFLOW_STR) {}
                explicit overflow_error(const char* var) : omni::exception(OMNI_OVERFLOW_STR) {
                    if (var) {
                        this->m_what.append(": ");
                        this->m_what.append(var);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit overflow_error(const std::string& var) : omni::exception(OMNI_OVERFLOW_STR) {
                    this->m_what.append(": ");
                    this->m_what.append(var);
                }
        };

        class underflow_error : public omni::exception
        {
            public:
                underflow_error() : omni::exception(OMNI_UNDERFLOW_STR) {}
                explicit underflow_error(const char* var) : omni::exception(OMNI_UNDERFLOW_STR) {
                    if (var) {
                        this->m_what.append(": ");
                        this->m_what.append(var);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit underflow_error(const std::string& var) : omni::exception(OMNI_UNDERFLOW_STR) {
                    this->m_what.append(": ");
                    this->m_what.append(var);
                }
        };
        
        class index_out_of_range : public omni::exception
        {
            public:
                index_out_of_range() : omni::exception(OMNI_INDEX_OOR_STR) {}
                index_out_of_range(const char* msg, std::size_t idx) : omni::exception(msg, idx) {}
                index_out_of_range(const std::string& msg, std::size_t idx) : omni::exception(msg, idx) {}
                explicit index_out_of_range(const char* var) : omni::exception(OMNI_INDEX_OOR_STR) {
                    if (var) {
                        this->m_what.append(": ");
                        this->m_what.append(var);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit index_out_of_range(const std::string& var) : omni::exception(OMNI_INDEX_OOR_STR) {
                    this->m_what.append(": ");
                    this->m_what.append(var);
                }
                explicit index_out_of_range(std::size_t idx) : omni::exception(OMNI_INDEX_OOR_STR) {
                    this->m_what.append(": ");
                    OMNI_ERR_APPEND_FW(idx);
                }
        };
        
        class invalid_application_state : public omni::exceptions::application_exception
        {
            public:
                invalid_application_state() : omni::exceptions::application_exception(OMNI_APP_RUNNING_STR) {}
        };
        
        class invalid_binary_format : public omni::exceptions::string_exception
        {
            public:
                invalid_binary_format() : omni::exceptions::string_exception(OMNI_STRING_INVALID_FORMAT_STR) {}
        };
        
        class invalid_binary_size : public omni::exceptions::string_exception
        {
            public:
                invalid_binary_size() : omni::exceptions::string_exception(OMNI_STRING_INVALID_SIZE_STR) {}
        };
        
        class invalid_delegate : public omni::exception
        {
            public:
                invalid_delegate() : omni::exception(OMNI_INVALID_DELEGATE_FUNC_STR) {}
        };
        
        class invalid_delegate_invoke : public omni::exception
        {
            public:
                invalid_delegate_invoke() : omni::exception(OMNI_INVALID_DELEGATE_INVOKE_STR) {}
        };
        
        class invalid_environment_variable : public omni::exceptions::environment_exception
        {
            public:
                invalid_environment_variable() : omni::exceptions::environment_exception(OMNI_ERR_NAME_STR) {}
        };

        class invalid_enum : public omni::exception
        {
            public:
                invalid_enum() : omni::exception(OMNI_INVALID_ENUM) {}
                explicit invalid_enum(const char* name) : omni::exception(OMNI_INVALID_ENUM) {
                    if (name) {
                        this->m_what.append(": ");
                        this->m_what.append(name);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit invalid_enum(const std::string& name) : omni::exception(OMNI_INVALID_ENUM) {
                    this->m_what.append(": ");
                    this->m_what.append(name);
                }
                explicit invalid_enum(int val) : omni::exception(OMNI_INVALID_ENUM, ": ", val) { }
                explicit invalid_enum(uint32_t val) : omni::exception(OMNI_INVALID_ENUM, ": ", static_cast<std::size_t>(val)) { }
                explicit invalid_enum(std::size_t val) : omni::exception(OMNI_INVALID_ENUM, ": ", val) { }
        };

        class invalid_parse : public omni::exception
        {
            public:
                invalid_parse() : omni::exception(OMNI_ERR_PARSE_STR) {}
                explicit invalid_parse(const char* msg) : omni::exception(msg) {}
        };
        
        class invalid_mutex_state : public omni::exceptions::mutex_system_exception
        {
            public:
                invalid_mutex_state() : omni::exceptions::mutex_system_exception(OMNI_ERR_MTX_STATE_STR) {}
        };
        
        class invalid_release_count : public omni::exceptions::semaphore_system_exception
        {
            public:
                invalid_release_count() : omni::exceptions::semaphore_system_exception(OMNI_ERR_RELEASE_STR) {}
        };

        class invalid_range : public omni::exception
        {
            public:
                invalid_range() : omni::exception(OMNI_ERR_RANGE_STR) {}
                explicit invalid_range(const char* msg) : omni::exception(msg) {}
        };
        
        class invalid_size : public omni::exception
        {
            public:
                invalid_size() : omni::exception(OMNI_ERR_SIZE_STR) {}
        };
        
        class invalid_template_type : public omni::exception
        {
            public:
                invalid_template_type() : omni::exception(OMNI_INVALID_TEMPLATE_STR) {}
        };
        
        class invalid_thread_state : public omni::exceptions::thread_exception
        {
            public:
             invalid_thread_state() : omni::exceptions::thread_exception(OMNI_INVALID_THREAD_STATE_STR) {}
        };
        
        class invalid_thread_handle : public omni::exceptions::thread_exception
        {
            public:
                invalid_thread_handle() : omni::exceptions::thread_exception(OMNI_INVALID_THREAD_HANDLE_STR) {}
        };
        
        class invalid_thread_option : public omni::exceptions::thread_exception
        {
            public:
                invalid_thread_option() : omni::exceptions::thread_exception(OMNI_INVALID_OPTION_STR) {}
                explicit invalid_thread_option(std::size_t var) : omni::exceptions::thread_exception(OMNI_INVALID_OPTION_STR, ": ", var) {}
        };
        
        class invalid_thread_owner : public omni::exceptions::thread_exception
        {
            public:
                invalid_thread_owner() : omni::exceptions::thread_exception(OMNI_INVALID_THREAD_OWNER) {}
        };
        
        class invalid_thread_start_type : public omni::exceptions::thread_exception
        {
            public:
                invalid_thread_start_type() : omni::exceptions::thread_exception(OMNI_INVALID_THREAD_START_TYPE_STR) {}
        };
        
        class invalid_threadpool_size : public omni::exceptions::threadpool_exception
        {
            public:
                invalid_threadpool_size() : omni::exceptions::threadpool_exception(OMNI_INVALID_SIZE_STR) {}
        };
        
        class invalid_type_cast : public omni::exception
        {
            public:
                invalid_type_cast() : omni::exception(OMNI_INVALID_CAST_STR) {}
        };
        
        class invalid_version : public omni::exception
        {
            public:
                invalid_version() : omni::exception(OMNI_INVALID_VERSION_STR) {}
        };
        
        class mutex_unlock_exception : public omni::exceptions::mutex_system_exception
        {
            public:
                mutex_unlock_exception() : omni::exceptions::mutex_system_exception(OMNI_ERR_MTX_UNLOCKED_STR) {}
        };
        
        class null_pointer_exception : public omni::exception
        {
            public:
                null_pointer_exception() : omni::exception(OMNI_NULL_REF_STR) {}
                explicit null_pointer_exception(const char* variable) : omni::exception(OMNI_NULL_REF_STR) {
                    if (variable) {
                        this->m_what.append(" on ");
                        this->m_what.append(variable);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit null_pointer_exception(const std::string& variable) : omni::exception(OMNI_NULL_REF_STR) {
                    this->m_what.append(" on ");
                    this->m_what.append(variable);
                }
        };
        
        class path_exception : public omni::exception
        {
            public:
                path_exception() : omni::exception(OMNI_PATH_ERROR) {}
                explicit path_exception(const char* path) : omni::exception(OMNI_PATH_ERROR) {
                    if (path) {
                        this->m_what.append(" on ");
                        this->m_what.append(path);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit path_exception(const std::string& path) : omni::exception(OMNI_PATH_ERROR) {
                    this->m_what.append(" on ");
                    this->m_what.append(path);
                }
        };

        class file_not_found : public omni::exception
        {
            public:
                file_not_found() : omni::exception(OMNI_FILE_NOT_FOUND_STR) {}
                explicit file_not_found(const char* path) : omni::exception(OMNI_FILE_NOT_FOUND_STR) {
                    if (path) {
                        this->m_what.append(": ");
                        this->m_what.append(path);
                    } else {
                        OMNI_DBGE(OMNI_NULL_PTR_STR);
                        OMNI_EXCEPTION_TERMINATE
                    }
                }
                explicit file_not_found(const std::string& path) : omni::exception(OMNI_FILE_NOT_FOUND_STR) {
                    this->m_what.append(": ");
                    this->m_what.append(path);
                }
        };

        class pipe_exception : public omni::exceptions::environment_exception
        {
            public:
                pipe_exception() : omni::exceptions::environment_exception(OMNI_ERR_PIPE_STR) {}
        };
        
        class semaphore_release_exception : public omni::exceptions::semaphore_system_exception
        {
            public:
                semaphore_release_exception() : omni::exceptions::semaphore_system_exception(OMNI_ERR_SEM_STATE_STR) {}
        };
        
        class spin_lock_exception : public omni::exception
        {
            public:
                spin_lock_exception() : omni::exception(OMNI_ERR_SPIN_OBJ_STR) {}
                spin_lock_exception(int err) : omni::exception(OMNI_ERR_SPIN_OBJ_STR, ": ", err) {}
        };
        
        class stopwatch_exception : public omni::exception
        {
            public:
                stopwatch_exception() : omni::exception(OMNI_ERR_STOPWATCH_STR) {}
                stopwatch_exception(const char* msg, int er) : omni::exception(msg, er) {}
                stopwatch_exception(const char* msg, long er) : omni::exception(msg ,er) {}
                explicit stopwatch_exception(const char* msg) : omni::exception(msg) {}
                explicit stopwatch_exception(int er) : omni::exception(OMNI_ERR_STOPWATCH_STR, ": ", er) {}
                explicit stopwatch_exception(long er) : omni::exception(OMNI_ERR_STOPWATCH_STR, ": ", er) {}
        };
        
        class thread_running_exception : public omni::exceptions::thread_exception
        {
            public:
                thread_running_exception() : omni::exceptions::thread_exception(OMNI_THREAD_STARTED_STR) {}
        };
        
        class threadpool_state_exception : public omni::exceptions::threadpool_exception
        {
            public:
                threadpool_state_exception() : omni::exceptions::threadpool_exception(OMNI_ERR_STATE_STR) {}
        };
        
        class threadpool_thread_exception : public omni::exceptions::threadpool_exception
        {
            public:
                threadpool_thread_exception() : omni::exceptions::threadpool_exception(OMNI_ERR_ACQUIRE_STR) {}
        };
    } // namespace exceptions    
} // namespace omni