summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/LocalExceptionWrapper.java
blob: 36d99f391b72086e446241ef3e1ba33faa2604da (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
// **********************************************************************
//
// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

package IceInternal;

public class LocalExceptionWrapper extends Exception
{
    public
    LocalExceptionWrapper(Ice.LocalException ex, boolean retry)
    {
        _ex = ex;
        _retry = retry;
    }

    public
    LocalExceptionWrapper(IceInternal.LocalExceptionWrapper ex)
    {
        _ex = ex.get();
        _retry = ex._retry;
    }

    public Ice.LocalException
    get()
    {
        return _ex;
    }

    //
    // If true, always repeat the request. Don't take retry settings
    // or "at-most-once" guarantees into account.
    //
    // If false, only repeat the request if the retry settings allow
    // to do so, and if "at-most-once" does not need to be guaranteed.
    //
    public boolean
    retry()
    {
        return _retry;
    }

    public static void
    throwUnknownWrapper(java.lang.Throwable ex) throws LocalExceptionWrapper
    {
        if(ex instanceof Ice.UserException)
        {
            throw new LocalExceptionWrapper(new Ice.UnknownUserException(ex.toString()), false);
        }
        if(ex instanceof Ice.LocalException)
        {
            /*
            //
            // Commented-out code makes local exceptions fully location transparent,
            // but the Freeze evictor relies on them not being transparent.
            //
            if(ex instanceof Ice.UnknownException ||
               ex instanceof Ice.ObjectNotExistException ||
               ex instanceof Ice.OperationNotExistException ||
               ex instanceof Ice.FacetNotExistException)
            {
                throw new LocalExceptionWrapper((Ice.LocalException)ex, false);
            }
            throw new LocalExceptionWrapper(new Ice.UnknownLocalException(ex.toString()), false);
            */
            throw new LocalExceptionWrapper((Ice.LocalException)ex, false);
        }
        /*
        throw new LocalExceptionWrapper(new Ice.UnknownException(ex.toString()), false);
        */

        if(ex instanceof RuntimeException)
        {
            throw (RuntimeException)ex;
        }
    }

    private Ice.LocalException _ex;
    private boolean _retry;
}