summaryrefslogtreecommitdiff
path: root/swift/test/Ice/exceptions/TestI.swift
blob: 08235a48e6a86b89bf0eb6749d6a6d4e1b974ca4 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

import Ice
import TestCommon

class RuntimeError: Error {}

class ThrowerI: Thrower {
    func shutdown(current: Ice.Current) throws {
        current.adapter!.getCommunicator().shutdown()
    }

    func supportsUndeclaredExceptions(current _: Current) throws -> Bool {
        return true
    }

    func supportsAssertException(current _: Current) throws -> Bool {
        return false
    }

    func throwAasA(a: Int32, current _: Ice.Current) throws {
        throw A(aMem: a)
    }

    func throwAorDasAorD(a: Int32, current _: Ice.Current) throws {
        if a > 0 {
            throw A(aMem: a)
        } else {
            throw D(dMem: a)
        }
    }

    func throwBasA(a: Int32, b: Int32, current: Ice.Current) throws {
        try throwBasB(a: a, b: b, current: current)
    }

    func throwBasB(a: Int32, b: Int32, current _: Ice.Current) throws {
        let ex = B()
        ex.aMem = a
        ex.bMem = b
        throw ex
    }

    func throwCasA(a: Int32, b: Int32, c: Int32, current: Ice.Current) throws {
        try throwCasC(a: a, b: b, c: c, current: current)
    }

    func throwCasB(a: Int32, b: Int32, c: Int32, current: Ice.Current) throws {
        try throwCasC(a: a, b: b, c: c, current: current)
    }

    func throwCasC(a: Int32, b: Int32, c: Int32, current _: Ice.Current) throws {
        throw C(aMem: a, bMem: b, cMem: c)
    }

    func throwModA(a _: Int32, a2 _: Int32, current _: Current) throws {
        throw ModA(aMem: 1, a2Mem: 1)
    }

    func throwLocalException(current _: Ice.Current) throws {
        throw Ice.TimeoutException()
    }

    func throwNonIceException(current _: Ice.Current) throws {
        throw RuntimeError()
    }

    func throwAssertException(current _: Ice.Current) throws {}

    func throwMemoryLimitException(seq _: ByteSeq, current _: Ice.Current) throws -> ByteSeq {
        return ByteSeq(repeating: 0, count: 1024 * 20) // 20KB is over the configured 10KB message size max.
    }

    func throwLocalExceptionIdempotent(current _: Ice.Current) throws {
        throw Ice.TimeoutException()
    }

    func throwUndeclaredA(a: Int32, current _: Ice.Current) throws {
        throw A(aMem: a)
    }

    func throwUndeclaredB(a: Int32, b: Int32, current _: Ice.Current) throws {
        throw B(aMem: a, bMem: b)
    }

    func throwUndeclaredC(a: Int32, b: Int32, c: Int32, current _: Ice.Current) throws {
        throw C(aMem: a, bMem: b, cMem: c)
    }

    func throwAfterResponse(current _: Ice.Current) throws {
        //
        // Only relevant for AMD.
        //
    }

    func throwAfterException(current _: Ice.Current) throws {
        //
        // Only relevant for AMD.
        //
        throw A()
    }
}