• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_MINDRECORD_INCLUDE_SHARD_ERROR_H_
18 #define MINDSPORE_CCSRC_MINDDATA_MINDRECORD_INCLUDE_SHARD_ERROR_H_
19 
20 #include <map>
21 #include <string>
22 #include "include/api/status.h"
23 
24 namespace mindspore {
25 namespace mindrecord {
26 #define RETURN_IF_NOT_OK(_s) \
27   do {                       \
28     Status __rc = (_s);      \
29     if (__rc.IsError()) {    \
30       return __rc;           \
31     }                        \
32   } while (false)
33 
34 #define RELEASE_AND_RETURN_IF_NOT_OK(_s, _db, _in) \
35   do {                                             \
36     Status __rc = (_s);                            \
37     if (__rc.IsError()) {                          \
38       if ((_db) != nullptr) {                      \
39         sqlite3_close(_db);                        \
40       }                                            \
41       (_in).close();                               \
42       return __rc;                                 \
43     }                                              \
44   } while (false)
45 
46 #define CHECK_FAIL_RETURN_UNEXPECTED(_condition, _e)                         \
47   do {                                                                       \
48     if (!(_condition)) {                                                     \
49       return Status(StatusCode::kMDUnexpectedError, __LINE__, __FILE__, _e); \
50     }                                                                        \
51   } while (false)
52 
53 #define RETURN_UNEXPECTED_IF_NULL(_ptr)                                         \
54   do {                                                                          \
55     if ((_ptr) == nullptr) {                                                    \
56       std::string err_msg = "The pointer[" + std::string(#_ptr) + "] is null."; \
57       RETURN_STATUS_UNEXPECTED(err_msg);                                        \
58     }                                                                           \
59   } while (false)
60 
61 #define RETURN_STATUS_UNEXPECTED(_e)                                       \
62   do {                                                                     \
63     return Status(StatusCode::kMDUnexpectedError, __LINE__, __FILE__, _e); \
64   } while (false)
65 
66 enum MSRStatus {
67   SUCCESS = 0,
68   FAILED = 1,
69 };
70 
71 }  // namespace mindrecord
72 }  // namespace mindspore
73 
74 #endif  // MINDSPORE_CCSRC_MINDDATA_MINDRECORD_INCLUDE_SHARD_ERROR_H_
75