mxnet
c_api_error.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
25 #ifndef MXNET_C_API_ERROR_H_
26 #define MXNET_C_API_ERROR_H_
27 
34 #define MX_API_BEGIN() try { on_enter_api(__FUNCTION__);
35 #define MX_API_END() } catch(dmlc::Error &_except_) { on_exit_api(); return MXAPIHandleException(_except_); } on_exit_api(); return 0; // NOLINT(*)
36 #define MX_API_END_HANDLE_ERROR(Finalize) } catch(dmlc::Error &_except_) { Finalize; on_exit_api(); return MXAPIHandleException(_except_); } on_exit_api(); return 0; // NOLINT(*)
37 
41 void MXAPISetLastError(const char* msg);
47 inline int MXAPIHandleException(const dmlc::Error &e) {
48  MXAPISetLastError(e.what());
49  return -1;
50 }
51 
52 namespace mxnet {
53 extern void on_enter_api(const char *function);
54 extern void on_exit_api();
55 }
56 #endif // MXNET_C_API_ERROR_H_
int MXAPIHandleException(const dmlc::Error &e)
handle exception throwed out
Definition: c_api_error.h:47
namespace of mxnet
Definition: base.h:118
void on_enter_api(const char *function)
void MXAPISetLastError(const char *msg)
Set the last error message needed by C API.
void on_exit_api()