forked from facebook/wdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrorCodes.h
78 lines (70 loc) · 2.87 KB
/
ErrorCodes.h
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
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#pragma once
#include <wdt/WdtConfig.h>
#include <string>
namespace facebook {
namespace wdt {
// For now just does regular check, for some library embedding may consider
// skipping or being DCHECK
#define WDT_CHECK CHECK
#define WDT_CHECK_EQ CHECK_EQ
#define WDT_CHECK_NE CHECK_NE
#define WDT_CHECK_LE CHECK_LE
#define WDT_CHECK_LT CHECK_LT
#define WDT_CHECK_GE CHECK_GE
#define WDT_CHECK_GT CHECK_GT
// Note : All the new errors should be defined at the end
#define ERRORS \
X(OK) /** No error */ \
X(ERROR) /** Generic error */ \
X(ABORT) /** Abort */ \
X(CONN_ERROR) /** Connection Error */ \
X(CONN_ERROR_RETRYABLE) /** Retryable connection error */ \
X(SOCKET_READ_ERROR) /** Socket read error */ \
X(SOCKET_WRITE_ERROR) /** Socket write error */ \
X(BYTE_SOURCE_READ_ERROR) /** Byte source(file) read error */ \
X(FILE_WRITE_ERROR) /** file write error */ \
X(MEMORY_ALLOCATION_ERROR) /** Memory allocation failure */ \
X(PROTOCOL_ERROR) /** WDT protocol error */ \
X(VERSION_MISMATCH) /** Sender and Receiver version mismatch */ \
X(ID_MISMATCH) /** Sender and Receiver id mismatch*/ \
X(CHECKSUM_MISMATCH) /** Checksums do not match */ \
X(RESOURCE_NOT_FOUND) /** Not found in the resource controller */ \
X(ABORTED_BY_APPLICATION) /** Transfer was aborted by application */ \
X(VERSION_INCOMPATIBLE) /** Sender/receiver version incompatible */ \
X(NOT_FOUND) /** Not found in the resource controller */ \
X(QUOTA_EXCEEDED) /** Quota exceeded in resource controller */ \
X(FEWER_PORTS) /** Couldn't listen on all the ports */ \
X(URI_PARSE_ERROR) /** Wdt uri passed couldn't be parsed*/
enum ErrorCode {
#define X(A) A,
ERRORS
#undef X
};
std::string const kErrorToStr[] = {
#define X(A) #A,
ERRORS
#undef X
};
/**
* returns string description of an error code
*
* @param code error-code
* @return string representation
*/
std::string errorCodeToStr(ErrorCode code);
/**
* Thread safe version of strerror(), easier than strerror_r
* (similar to folly::errnoStr() but without pulling in all the dependencies)
*/
std::string strerrorStr(int errnum);
}
}
#undef ERRORS