aboutsummaryrefslogtreecommitdiffstats
path: root/fnet/src/vespa/fnet/frt/error.cpp
blob: fb91924bf35f96295ecf50d12f5ef82c6f57516a (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "error.h"

const char *
FRT_GetErrorCodeName(uint32_t errorCode)
{
    if (errorCode == 0) return "FRTE_NO_ERROR";
    if (errorCode > 0xffff) return "[APPLICATION ERROR]";

    if (errorCode >= FRTE_RPC_FIRST &&
        errorCode <= FRTE_RPC_LAST)
    {
        switch (errorCode) {
        case FRTE_RPC_GENERAL_ERROR:     return "FRTE_RPC_GENERAL_ERROR";
        case FRTE_RPC_NOT_IMPLEMENTED:   return "FRTE_RPC_NOT_IMPLEMENTED";
        case FRTE_RPC_ABORT:             return "FRTE_RPC_ABORT";
        case FRTE_RPC_TIMEOUT:           return "FRTE_RPC_TIMEOUT";
        case FRTE_RPC_CONNECTION:        return "FRTE_RPC_CONNECTION";
        case FRTE_RPC_BAD_REQUEST:       return "FRTE_RPC_BAD_REQUEST";
        case FRTE_RPC_NO_SUCH_METHOD:    return "FRTE_RPC_NO_SUCH_METHOD";
        case FRTE_RPC_WRONG_PARAMS:      return "FRTE_RPC_WRONG_PARAMS";
        case FRTE_RPC_OVERLOAD:          return "FRTE_RPC_OVERLOAD";
        case FRTE_RPC_WRONG_RETURN:      return "FRTE_RPC_WRONG_RETURN";
        case FRTE_RPC_BAD_REPLY:         return "FRTE_RPC_BAD_REPLY";
        case FRTE_RPC_METHOD_FAILED:     return "FRTE_RPC_METHOD_FAILED";
        case FRTE_RPC_PERMISSION_DENIED: return "FRTE_RPC_PERMISSION_DENIED";
        default:                         return "[UNKNOWN RPC ERROR]";
        }
    }
    return "[UNKNOWN ERROR]";
}


const char *
FRT_GetDefaultErrorMessage(uint32_t errorCode)
{
    if (errorCode == 0) return "No error";
    if (errorCode > 0xffff) return "[APPLICATION ERROR]";

    if (errorCode >= FRTE_RPC_FIRST &&
        errorCode <= FRTE_RPC_LAST)
    {
        switch (errorCode) {
        case FRTE_RPC_GENERAL_ERROR:     return "(RPC) General error";
        case FRTE_RPC_NOT_IMPLEMENTED:   return "(RPC) Not implemented";
        case FRTE_RPC_ABORT:             return "(RPC) Invocation aborted";
        case FRTE_RPC_TIMEOUT:           return "(RPC) Invocation timed out";
        case FRTE_RPC_CONNECTION:        return "(RPC) Connection error";
        case FRTE_RPC_BAD_REQUEST:       return "(RPC) Bad request packet";
        case FRTE_RPC_NO_SUCH_METHOD:    return "(RPC) No such method";
        case FRTE_RPC_WRONG_PARAMS:      return "(RPC) Illegal parameters";
        case FRTE_RPC_OVERLOAD:          return "(RPC) Request dropped due to server overload";
        case FRTE_RPC_WRONG_RETURN:      return "(RPC) Illegal return values";
        case FRTE_RPC_BAD_REPLY:         return "(RPC) Bad reply packet";
        case FRTE_RPC_METHOD_FAILED:     return "(RPC) Method failed";
        case FRTE_RPC_PERMISSION_DENIED: return "(RPC) Permission denied";
        default:                         return "[UNKNOWN RPC ERROR]";
        }
    }
    return "[UNKNOWN ERROR]";
}