Skip to content

Commit c317e9c

Browse files
Handle possible exception from calling ext_oneapi_default_context() method
1 parent 330746b commit c317e9c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

libsyclinterface/source/dpctl_sycl_platform_interface.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,17 @@ DPCTLPlatform_GetDefaultContext(__dpctl_keep const DPCTLSyclPlatformRef PRef)
225225
{
226226
auto P = unwrap<platform>(PRef);
227227
if (P) {
228-
const auto &default_ctx = P->ext_oneapi_get_default_context();
229-
return wrap<context>(new context(default_ctx));
228+
#ifdef SYCL_EXT_ONEAPI_DEFAULT_CONTEXT
229+
try {
230+
const auto &default_ctx = P->ext_oneapi_get_default_context();
231+
return wrap<context>(new context(default_ctx));
232+
} catch (const std::exception &ex) {
233+
error_handler(ex, __FILE__, __func__, __LINE__);
234+
return nullptr;
235+
}
236+
#else
237+
return nullptr;
238+
#endif
230239
}
231240
else {
232241
error_handler(

0 commit comments

Comments
 (0)