aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsample/exceptiontest.cpp
blob: 35da4e90b0dd7687ebdea7186ccd542f6ab110fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "exceptiontest.h"

class TestException : public std::exception
{
public:
    const char *what() const noexcept override
    { return "TestException"; }
};

ExceptionTest::ExceptionTest() = default;

int ExceptionTest::intThrowStdException(bool doThrow)
{
    if (doThrow)
        throw TestException();
    return 1;
}

void ExceptionTest::voidThrowStdException(bool doThrow)
{
    if (doThrow)
        throw TestException();
}

int ExceptionTest::intThrowInt(bool doThrow)
{
    if (doThrow)
        throw 42;
    return 1;
}

void ExceptionTest::voidThrowInt(bool doThrow)
{
    if (doThrow)
        throw 42;
}