Oracle Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.2)

E26041-01

coherence/lang/IllegalArgumentException.hpp

00001 /*
00002 * IllegalArgumentException.hpp
00003 *
00004 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_ILLEGAL_ARGUMENT_EXCEPTION_HPP
00017 #define COH_ILLEGAL_ARGUMENT_EXCEPTION_HPP
00018 
00019 #include "coherence/lang/compatibility.hpp"
00020 
00021 #include "coherence/lang/RuntimeException.hpp"
00022 #include "coherence/lang/String.hpp"
00023 
00024 COH_OPEN_NAMESPACE2(coherence,lang)
00025 
00026 
00027 /**
00028 * Thrown to indicate that a function has been passed an illegal or
00029 * inappropriate argument.
00030 */
00031 class COH_EXPORT IllegalArgumentException
00032     : public throwable_spec<IllegalArgumentException,
00033         extends<RuntimeException, std::invalid_argument> >
00034     {
00035     friend class factory<IllegalArgumentException>;
00036 
00037     // ----- constructors ---------------------------------------------------
00038 
00039     protected:
00040         /**
00041         * Create an IllegalArgumentException.
00042         *
00043         * @param vsMsg   the detail message
00044         * @param vCause  the underlying cause of the exception
00045         *
00046         * @return a new IllegalArgumentException
00047         */
00048         IllegalArgumentException(String::View vsMsg = String::null_string,
00049                 Exception::View vCause = NULL);
00050     };
00051 
00052 
00053 // ------ helper macros -----------------------------------------------------
00054 
00055 /**
00056 * Ensure the relation between two expressions.
00057 *
00058 * @param PARAM  the parameter expression
00059 * @param OP     the expected relation, i.e. ==, <, >, ...
00060 * @param VALUE  the right expression
00061 *
00062 * @throw IllegalArgumentException if an unexpected result is returned
00063 */
00064 #define COH_ENSURE_PARAM_RELATION(PARAM, OP, VALUE) \
00065     if (!(PARAM OP VALUE)) \
00066         { \
00067         COH_THROW_STREAM (coherence::lang::IllegalArgumentException, \
00068             #PARAM << " is " << PARAM << "; must be " << #OP << " " << #VALUE); \
00069         }
00070 
00071 /**
00072 * Ensure that a handle/view is not NULL.
00073 *
00074 * @param HANDLE  the handle/view to check for NULL
00075 *
00076 * @throw IllegalArgumentException if the passed in handle/view is NULL
00077 */
00078 #define COH_ENSURE_PARAM(HANDLE) COH_ENSURE_PARAM_RELATION(HANDLE, !=, NULL)
00079 
00080 COH_CLOSE_NAMESPACE2
00081 
00082 #endif // COH_ILLEGAL_ARGUMENT_EXCEPTION_HPP
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.