Skip to content

Commit e2e92c0

Browse files
jacek-galazkaigcbot
authored andcommitted
Better handle exception messages
Better handle exception messages
1 parent d79b9d6 commit e2e92c0

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

IGC/AdaptorOCL/dllInterfaceCompute.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ bool CIGCTranslationBlock::Translate(
303303
return false;
304304
}
305305
}
306+
catch (std::exception& e)
307+
{
308+
if (pOutputArgs->ErrorStringSize == 0 && pOutputArgs->pErrorString == nullptr)
309+
{
310+
SetErrorMessage(std::string("IGC: ") + e.what(), *pOutputArgs);
311+
}
312+
return false;
313+
}
306314
catch (...)
307315
{
308316
if (pOutputArgs->ErrorStringSize == 0 && pOutputArgs->pErrorString == nullptr)
@@ -1320,30 +1328,13 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs,
13201328
}
13211329
catch (std::exception &e)
13221330
{
1323-
if (oclContext.HasError() && oclContext.HasWarning())
1324-
{
1325-
SetOutputMessage(oclContext.GetErrorAndWarning(), *pOutputArgs);
1326-
}
1327-
else
1328-
{
1329-
if (oclContext.HasError())
1330-
{
1331-
SetOutputMessage(oclContext.GetError(), *pOutputArgs);
1332-
}
1333-
if (oclContext.HasWarning())
1334-
{
1335-
SetOutputMessage(oclContext.GetWarning(), *pOutputArgs);
1336-
}
1337-
}
1338-
1339-
if (e.what() != nullptr)
1340-
{
1341-
SetErrorMessage(e.what(), *pOutputArgs);
1342-
}
1343-
13441331
if (pOutputArgs->ErrorStringSize == 0 && pOutputArgs->pErrorString == nullptr)
13451332
{
1346-
SetErrorMessage("IGC: Internal Compiler Error", *pOutputArgs);
1333+
std::string message = "IGC: ";
1334+
message += oclContext.GetErrorAndWarning();
1335+
message += '\n';
1336+
message += e.what();
1337+
SetErrorMessage(message.c_str(), *pOutputArgs);
13471338
}
13481339
return false;
13491340
}

IGC/AdaptorOCL/ocl_igc_interface/impl/igc_ocl_translation_ctx_impl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,16 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
350350
}
351351
}
352352
}
353+
catch (std::exception& e)
354+
{
355+
success = false;
356+
if (output.ErrorStringSize == 0 && output.pErrorString == nullptr)
357+
{
358+
std::string msg = "IGC: ";
359+
msg += e.what();
360+
outputInterface->GetImpl()->SetError(TranslationErrorType::FailedCompilation, msg.c_str());
361+
}
362+
}
353363
catch (...)
354364
{
355365
success = false;

0 commit comments

Comments
 (0)