Catch all exceptions by reference

This commit is contained in:
Sujin Philip 2017-02-23 10:13:30 -05:00
parent 57ad3c8cb5
commit a88807fd7e
22 changed files with 49 additions and 49 deletions

@ -128,7 +128,7 @@ void Storage<T, vtkm::cont::StorageTagBasic>::Allocate(vtkm::Id numberOfValues)
VTKM_ASSERT(this->AllocatedSize == 0);
}
}
catch (std::bad_alloc err)
catch (std::bad_alloc&)
{
// Make sureour state is OK.
this->Array = nullptr;

@ -59,31 +59,31 @@ struct TryExecuteRunIfValid<Functor, Device, true>
{
return functor(Device());
}
catch(vtkm::cont::ErrorBadAllocation e)
catch(vtkm::cont::ErrorBadAllocation &e)
{
std::cerr << "caught ErrorBadAllocation " << e.GetMessage() << std::endl;
//currently we only consider OOM errors worth disabling a device for
//than we fallback to another device
tracker.ReportAllocationFailure(Device(), e);
}
catch(vtkm::cont::ErrorBadType e)
catch(vtkm::cont::ErrorBadType &e)
{
//should bad type errors should stop the execution, instead of
//deferring to another device adapter?
std::cerr << "caught ErrorBadType : " << e.GetMessage() << std::endl;
}
catch(vtkm::cont::ErrorBadValue e)
catch(vtkm::cont::ErrorBadValue &e)
{
//should bad value errors should stop the filter, instead of deferring
//to another device adapter?
std::cerr << "caught ErrorBadValue : " << e.GetMessage() << std::endl;
}
catch(vtkm::cont::Error e)
catch(vtkm::cont::Error &e)
{
//general errors should be caught and let us try the next device adapter.
std::cerr << "exception is: " << e.GetMessage() << std::endl;
}
catch (std::exception e)
catch (std::exception &e)
{
std::cerr << "caught standard exception: " << e.what() << std::endl;
}

@ -60,7 +60,7 @@ public:
// with nvcc 7.5.
return this->Superclass::template _PrepareForInput<void>(updateData);
}
catch (vtkm::cont::ErrorBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation &error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();
@ -81,7 +81,7 @@ public:
// with nvcc 7.5.
return this->Superclass::template _PrepareForInPlace<void>(updateData);
}
catch (vtkm::cont::ErrorBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation &error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();
@ -102,7 +102,7 @@ public:
// with nvcc 7.5.
return this->Superclass::template _PrepareForOutput<void>(numberOfValues);
}
catch (vtkm::cont::ErrorBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation &error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();

@ -474,7 +474,7 @@ VTKM_VECTORIZATION_IN_LOOP
this->Functor(index);
}
}
catch (vtkm::cont::Error error)
catch (vtkm::cont::Error &error)
{
this->ErrorMessage.RaiseError(error.GetMessage().c_str());
}
@ -526,7 +526,7 @@ VTKM_VECTORIZATION_IN_LOOP
}
}
}
catch (vtkm::cont::Error error)
catch (vtkm::cont::Error &error)
{
this->ErrorMessage.RaiseError(error.GetMessage().c_str());
}
@ -574,7 +574,7 @@ VTKM_VECTORIZATION_IN_LOOP
OutputPortal.Set( i, ValuesPortal.Get(IndexPortal.Get(i)) );
}
}
catch (vtkm::cont::Error error)
catch (vtkm::cont::Error &error)
{
this->ErrorMessage.RaiseError(error.GetMessage().c_str());
}

@ -38,20 +38,20 @@ public:
{
function();
}
catch (vtkm::testing::Testing::TestFailure error)
catch (vtkm::testing::Testing::TestFailure &error)
{
std::cout << "***** Test failed @ "
<< error.GetFile() << ":" << error.GetLine() << std::endl
<< error.GetMessage() << std::endl;
return 1;
}
catch (vtkm::cont::Error error)
catch (vtkm::cont::Error &error)
{
std::cout << "***** Uncaught VTKm exception thrown." << std::endl
<< error.GetMessage() << std::endl;
return 1;
}
catch (std::exception error)
catch (std::exception &error)
{
std::cout << "***** STL exception throw." << std::endl
<< error.what() << std::endl;

@ -90,7 +90,7 @@ private:
ds.GetField("cellvar", vtkm::cont::Field::ASSOC_POINTS);
VTKM_TEST_FAIL("Failed to get expected error for association mismatch.");
}
catch (vtkm::cont::ErrorBadValue error)
catch (vtkm::cont::ErrorBadValue &error)
{
std::cout << "Caught expected error for association mismatch: "
<< std::endl << " " << error.GetMessage() << std::endl;

@ -423,7 +423,7 @@ private:
"or the width of vtkm::Id is not large enough to express all "
"array sizes.");
}
catch (vtkm::cont::ErrorBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation &error)
{
std::cout << "Got the expected error: " << error.GetMessage() << std::endl;
}
@ -1559,7 +1559,7 @@ private:
{
Algorithm::Schedule(OneErrorKernel(), ARRAY_SIZE);
}
catch (vtkm::cont::ErrorExecution error)
catch (vtkm::cont::ErrorExecution &error)
{
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
message = error.GetMessage();
@ -1573,7 +1573,7 @@ private:
{
Algorithm::Schedule(AllErrorKernel(), ARRAY_SIZE);
}
catch (vtkm::cont::ErrorExecution error)
catch (vtkm::cont::ErrorExecution &error)
{
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
message = error.GetMessage();

@ -331,7 +331,7 @@ void TestBadArrayLengths() {
vtkm::cont::make_ArrayHandleCompositeVector(longInArray,0, shortInArray,0);
VTKM_TEST_FAIL("Did not get exception like expected.");
}
catch (vtkm::cont::ErrorBadValue error)
catch (vtkm::cont::ErrorBadValue &error)
{
std::cout << "Got expected error: " << std::endl
<< error.GetMessage() << std::endl;

@ -99,7 +99,7 @@ struct Test
{
handle.PrepareForInput(DeviceTag());
}
catch (vtkm::cont::ErrorBadValue exp)
catch (vtkm::cont::ErrorBadValue&)
{
// Expected failure.
}
@ -108,7 +108,7 @@ struct Test
{
handle.PrepareForInPlace(DeviceTag());
}
catch (vtkm::cont::ErrorBadValue exp)
catch (vtkm::cont::ErrorBadValue&)
{
// Expected failure.
}

@ -264,7 +264,7 @@ void TryUnusualType()
CheckDynamicArray(array, 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type.");
}
catch (vtkm::cont::ErrorBadValue)
catch (vtkm::cont::ErrorBadValue&)
{
std::cout << " Caught exception for unrecognized type." << std::endl;
}
@ -286,7 +286,7 @@ void TryUnusualStorage()
CheckDynamicArray(array, 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage.");
}
catch (vtkm::cont::ErrorBadValue)
catch (vtkm::cont::ErrorBadValue&)
{
std::cout << " Caught exception for unrecognized storage." << std::endl;
}
@ -307,7 +307,7 @@ void TryUnusualTypeAndStorage()
VTKM_TEST_FAIL(
"CastAndCall failed to error for unrecognized type/storage.");
}
catch (vtkm::cont::ErrorBadValue)
catch (vtkm::cont::ErrorBadValue&)
{
std::cout << " Caught exception for unrecognized type/storage."
<< std::endl;
@ -318,7 +318,7 @@ void TryUnusualTypeAndStorage()
CheckDynamicArray(array.ResetTypeList(TypeListTagString()), 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage.");
}
catch (vtkm::cont::ErrorBadValue)
catch (vtkm::cont::ErrorBadValue&)
{
std::cout << " Caught exception for unrecognized storage." << std::endl;
}
@ -328,7 +328,7 @@ void TryUnusualTypeAndStorage()
CheckDynamicArray(array.ResetStorageList(StorageListTagUnusual()), 1);
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type.");
}
catch (vtkm::cont::ErrorBadValue)
catch (vtkm::cont::ErrorBadValue&)
{
std::cout << " Caught exception for unrecognized type." << std::endl;
}
@ -340,7 +340,7 @@ void TryUnusualTypeAndStorage()
StorageListTagUnusual()),
1);
}
catch (vtkm::cont::ErrorBadValue)
catch (vtkm::cont::ErrorBadValue&)
{
VTKM_TEST_FAIL("ResetTypeAndStorageLists should have handled the custom type/storage.");
}

@ -182,7 +182,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(true==false,
"Array shrink do a larger size was possible. This can't be allowed.");
}
catch(vtkm::cont::ErrorBadValue) {}
catch(vtkm::cont::ErrorBadValue&) {}
}
void operator()()

@ -85,7 +85,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(false == true,
"Implicit Storage Allocate method didn't throw error.");
}
catch(vtkm::cont::ErrorBadValue e) {}
catch(vtkm::cont::ErrorBadValue&) {}
try
{
@ -93,7 +93,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(true==false,
"Array shrink do a larger size was possible. This can't be allowed.");
}
catch(vtkm::cont::ErrorBadValue) {}
catch(vtkm::cont::ErrorBadValue&) {}
//verify that calling ReleaseResources doesn't throw an exception
arrayStorage.ReleaseResources();

@ -180,7 +180,7 @@ public:
this->GetField().GetData().CopyTo(dest);
return true;
}
catch(vtkm::cont::Error)
catch(vtkm::cont::Error&)
{
return false;
}

@ -77,13 +77,13 @@ private:
vtkm::interop::BufferState state(handle);
vtkm::interop::TransferToOpenGL(array, state, DeviceAdapterTag());
}
catch (vtkm::cont::ErrorBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation &error)
{
std::cout << error.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,
"Got an unexpected Out Of Memory error transferring to openGL");
}
catch (vtkm::cont::ErrorBadValue bvError)
catch (vtkm::cont::ErrorBadValue &bvError)
{
std::cout << bvError.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,
@ -100,13 +100,13 @@ private:
vtkm::interop::BufferState state(handle, type);
vtkm::interop::TransferToOpenGL(array, state, DeviceAdapterTag());
}
catch (vtkm::cont::ErrorBadAllocation error)
catch (vtkm::cont::ErrorBadAllocation &error)
{
std::cout << error.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,
"Got an unexpected Out Of Memory error transferring to openGL");
}
catch (vtkm::cont::ErrorBadValue bvError)
catch (vtkm::cont::ErrorBadValue &bvError)
{
std::cout << bvError.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,

@ -192,7 +192,7 @@ public:
this->CloseFile();
this->Loaded = true;
}
catch (std::ifstream::failure e)
catch (std::ifstream::failure &e)
{
std::string message("IO Error: ");
throw vtkm::io::ErrorIO(message + e.what());

@ -360,7 +360,7 @@ inline vtkm::cont::DataSet readVTKDataSet(const char *fname)
{
ds = reader.ReadDataSet();
}
catch (vtkm::io::ErrorIO e)
catch (vtkm::io::ErrorIO &e)
{
std::string message("Error reading: ");
message += fname;

@ -416,7 +416,7 @@ public:
this->Write(fileStream, dataSet, cellSetIndex);
fileStream.close();
}
catch (std::ofstream::failure error)
catch (std::ofstream::failure &error)
{
throw vtkm::io::ErrorIO(error.what());
}

@ -248,14 +248,14 @@ public:
{
function();
}
catch (TestFailure error)
catch (TestFailure &error)
{
std::cout << "***** Test failed @ "
<< error.GetFile() << ":" << error.GetLine() << std::endl
<< error.GetMessage() << std::endl;
return 1;
}
catch (std::exception error)
catch (std::exception &error)
{
std::cout << "***** STL exception throw." << std::endl
<< error.what() << std::endl;

@ -294,7 +294,7 @@ void TestInvokeWithError()
dispatcher.Invoke(inputArray, execObject, outputArray);
VTKM_TEST_FAIL("Exception not thrown.");
}
catch (vtkm::cont::ErrorExecution error)
catch (vtkm::cont::ErrorExecution &error)
{
std::cout << " Got expected exception." << std::endl;
VTKM_TEST_ASSERT(error.GetMessage() == ERROR_MESSAGE,
@ -318,7 +318,7 @@ void TestInvokeWithDynamicAndBadTypes()
dispatcher.Invoke(nullptr, execObject, array);
VTKM_TEST_FAIL("Dispatcher did not throw expected error.");
}
catch (vtkm::cont::ErrorBadType error)
catch (vtkm::cont::ErrorBadType &error)
{
std::cout << " Got expected exception." << std::endl;
std::cout << " " << error.GetMessage() << std::endl;
@ -332,7 +332,7 @@ void TestInvokeWithDynamicAndBadTypes()
dispatcher.Invoke(array, execObject, nullptr);
VTKM_TEST_FAIL("Dispatcher did not throw expected error.");
}
catch (vtkm::cont::ErrorBadType error)
catch (vtkm::cont::ErrorBadType &error)
{
std::cout << " Got expected exception." << std::endl;
std::cout << " " << error.GetMessage() << std::endl;

@ -125,7 +125,7 @@ struct DoStaticTestWorklet
{
dispatcher.Invoke(inputHandle, outputHandle, inoutHandle);
}
catch (vtkm::cont::ErrorBadValue error)
catch (vtkm::cont::ErrorBadValue &error)
{
std::cout << " Caught expected error: " << error.GetMessage()
<< std::endl;

@ -143,7 +143,7 @@ TestAvgPointToCell()
dataSet.GetField("cellvar"), // should be pointvar
result);
}
catch (vtkm::cont::ErrorBadValue error)
catch (vtkm::cont::ErrorBadValue &error)
{
std::cout << " Caught expected error: " << error.GetMessage()
<< std::endl;
@ -184,7 +184,7 @@ TestAvgCellToPoint()
dataSet.GetField("pointvar"), // should be cellvar
result);
}
catch (vtkm::cont::ErrorBadValue error)
catch (vtkm::cont::ErrorBadValue &error)
{
std::cout << " Caught expected error: " << error.GetMessage()
<< std::endl;

@ -185,7 +185,7 @@ TestAvgPointToCell()
dataSet.GetField("cellvar"), // should be pointvar
result);
}
catch (vtkm::cont::ErrorBadValue error)
catch (vtkm::cont::ErrorBadValue &error)
{
std::cout << " Caught expected error: " << error.GetMessage()
<< std::endl;
@ -236,7 +236,7 @@ TestAvgCellToPoint()
dataSet.GetField("pointvar"), // should be cellvar
result);
}
catch (vtkm::cont::ErrorBadValue error)
catch (vtkm::cont::ErrorBadValue &error)
{
std::cout << " Caught expected error: " << error.GetMessage()
<< std::endl;