1 /* 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_CAMERA_DPS_CATCH_H 17 #define OHOS_CAMERA_DPS_CATCH_H 18 19 #define ERROR_CODE() __catch_error_code 20 #define ERROR_LINE() __catch_error_line 21 #define ERROR_PROSS() __catch_error_line = __LINE__ 22 23 #define PROSS \ 24 int32_t __catch_error_code = 0x7FFFFFCC; \ 25 int32_t __catch_error_line = 0x7FFFFFFF; \ 26 { 27 #define END_PROSS \ 28 } \ 29 __tabErrorCode: 30 31 #define THROW(err) \ 32 do { \ 33 __catch_error_code = (err); \ 34 ERROR_PROSS(); \ 35 goto __tabErrorCode; \ 36 } while (0) 37 38 #define EXEC(func) \ 39 { \ 40 if (DP_OK != (__catch_error_code = (func))) \ 41 THROW(__catch_error_code); \ 42 } 43 44 #define JUDEG(err, expr) \ 45 { \ 46 if (!(expr)) { \ 47 THROW(err); \ 48 } \ 49 } 50 51 #define CATCH_ERROR \ 52 { 53 #define END_CATCH_ERROR } 54 55 #endif // OHOS_CAMERA_DPS_CATCH_H