xref: /aosp_15_r20/external/OpenCL-CTS/test_conformance/spir/exceptions.h (revision 6467f958c7de8070b317fc65bcb0f6472e388d82)
1*6467f958SSadaf Ebrahimi //
2*6467f958SSadaf Ebrahimi // Copyright (c) 2017 The Khronos Group Inc.
3*6467f958SSadaf Ebrahimi //
4*6467f958SSadaf Ebrahimi // Licensed under the Apache License, Version 2.0 (the "License");
5*6467f958SSadaf Ebrahimi // you may not use this file except in compliance with the License.
6*6467f958SSadaf Ebrahimi // You may obtain a copy of the License at
7*6467f958SSadaf Ebrahimi //
8*6467f958SSadaf Ebrahimi //    http://www.apache.org/licenses/LICENSE-2.0
9*6467f958SSadaf Ebrahimi //
10*6467f958SSadaf Ebrahimi // Unless required by applicable law or agreed to in writing, software
11*6467f958SSadaf Ebrahimi // distributed under the License is distributed on an "AS IS" BASIS,
12*6467f958SSadaf Ebrahimi // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*6467f958SSadaf Ebrahimi // See the License for the specific language governing permissions and
14*6467f958SSadaf Ebrahimi // limitations under the License.
15*6467f958SSadaf Ebrahimi //
16*6467f958SSadaf Ebrahimi #ifndef __EXCEPTIONS_H
17*6467f958SSadaf Ebrahimi #define __EXCEPTIONS_H
18*6467f958SSadaf Ebrahimi 
19*6467f958SSadaf Ebrahimi #include <stdexcept>
20*6467f958SSadaf Ebrahimi #include "miniz/miniz.h"
21*6467f958SSadaf Ebrahimi 
22*6467f958SSadaf Ebrahimi namespace Exceptions
23*6467f958SSadaf Ebrahimi {
24*6467f958SSadaf Ebrahimi     /**
25*6467f958SSadaf Ebrahimi     Exception thrown on error in command line parameters
26*6467f958SSadaf Ebrahimi     */
27*6467f958SSadaf Ebrahimi     class CmdLineError : public std::runtime_error
28*6467f958SSadaf Ebrahimi     {
29*6467f958SSadaf Ebrahimi     public:
CmdLineError(const std::string & msg)30*6467f958SSadaf Ebrahimi         CmdLineError (const std::string& msg): std::runtime_error(msg){}
31*6467f958SSadaf Ebrahimi     };
32*6467f958SSadaf Ebrahimi 
33*6467f958SSadaf Ebrahimi     /**
34*6467f958SSadaf Ebrahimi     Exception thrown on error in test run
35*6467f958SSadaf Ebrahimi     */
36*6467f958SSadaf Ebrahimi     class TestError : public std::runtime_error
37*6467f958SSadaf Ebrahimi     {
38*6467f958SSadaf Ebrahimi     public:
runtime_error(msg)39*6467f958SSadaf Ebrahimi         TestError (const std::string& msg, int errorCode = 1): std::runtime_error(msg), m_errorCode(errorCode){}
40*6467f958SSadaf Ebrahimi 
getErrorCode()41*6467f958SSadaf Ebrahimi         int getErrorCode() const { return m_errorCode; }
42*6467f958SSadaf Ebrahimi     private:
43*6467f958SSadaf Ebrahimi         int m_errorCode;
44*6467f958SSadaf Ebrahimi     };
45*6467f958SSadaf Ebrahimi 
46*6467f958SSadaf Ebrahimi     class ArchiveError : public std::runtime_error
47*6467f958SSadaf Ebrahimi     {
48*6467f958SSadaf Ebrahimi     public:
ArchiveError(int errCode)49*6467f958SSadaf Ebrahimi         ArchiveError(int errCode): std::runtime_error(mz_error(errCode)){}
50*6467f958SSadaf Ebrahimi     };
51*6467f958SSadaf Ebrahimi }
52*6467f958SSadaf Ebrahimi 
53*6467f958SSadaf Ebrahimi #endif
54