| 123 | } |
| 124 | |
| 125 | af_err processException() { |
| 126 | stringstream ss; |
| 127 | af_err err = AF_ERR_INTERNAL; |
| 128 | |
| 129 | try { |
| 130 | throw; |
| 131 | } catch (const DimensionError &ex) { |
| 132 | ss << "In function " << ex.getFunctionName() << "\n" |
| 133 | << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n" |
| 134 | << "Invalid dimension for argument " << ex.getArgIndex() << "\n" |
| 135 | << "Expected: " << ex.getExpectedCondition() << "\n"; |
| 136 | if (is_stacktrace_enabled()) { ss << ex.getStacktrace(); } |
| 137 | |
| 138 | err = set_global_error_string(ss.str(), AF_ERR_SIZE); |
| 139 | } catch (const ArgumentError &ex) { |
| 140 | ss << "In function " << ex.getFunctionName() << "\n" |
| 141 | << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n" |
| 142 | << "Invalid argument at index " << ex.getArgIndex() << "\n" |
| 143 | << "Expected: " << ex.getExpectedCondition() << "\n"; |
| 144 | |
| 145 | if (is_stacktrace_enabled()) { ss << ex.getStacktrace(); } |
| 146 | err = set_global_error_string(ss.str(), AF_ERR_ARG); |
| 147 | } catch (const SupportError &ex) { |
| 148 | ss << ex.getFunctionName() << " not supported for " |
| 149 | << ex.getBackendName() << " backend\n"; |
| 150 | |
| 151 | if (is_stacktrace_enabled()) { ss << ex.getStacktrace(); } |
| 152 | err = set_global_error_string(ss.str(), AF_ERR_NOT_SUPPORTED); |
| 153 | } catch (const TypeError &ex) { |
| 154 | ss << "In function " << ex.getFunctionName() << "\n" |
| 155 | << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n" |
| 156 | << "Invalid type for argument " << ex.getArgIndex() << "\n"; |
| 157 | |
| 158 | if (is_stacktrace_enabled()) { ss << ex.getStacktrace(); } |
| 159 | err = set_global_error_string(ss.str(), AF_ERR_TYPE); |
| 160 | } catch (const AfError &ex) { |
| 161 | ss << "In function " << ex.getFunctionName() << "\n" |
| 162 | << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n" |
| 163 | << ex.what() << "\n"; |
| 164 | if (is_stacktrace_enabled()) { ss << ex.getStacktrace(); } |
| 165 | |
| 166 | err = set_global_error_string(ss.str(), ex.getError()); |
| 167 | #ifdef AF_ONEAPI |
| 168 | } catch (const sycl::exception &ex) { |
| 169 | char oneapi_err_msg[1024]; |
| 170 | snprintf(oneapi_err_msg, sizeof(oneapi_err_msg), |
| 171 | "oneAPI Error (%d): %s", ex.code().value(), ex.what()); |
| 172 | |
| 173 | if (ex.code() == sycl::errc::memory_allocation) { |
| 174 | err = set_global_error_string(oneapi_err_msg, AF_ERR_NO_MEM); |
| 175 | } else { |
| 176 | err = set_global_error_string(oneapi_err_msg, AF_ERR_INTERNAL); |
| 177 | } |
| 178 | } catch (const oneapi::mkl::exception &ex) { |
| 179 | char oneapi_err_msg[1024]; |
| 180 | snprintf(oneapi_err_msg, sizeof(oneapi_err_msg), "MKL Error: %s", |
| 181 | ex.what()); |
| 182 |
nothing calls this directly
no test coverage detected