Skip to content
Snippets Groups Projects
Commit 7bee4c9a authored by Nicola Vigano's avatar Nicola Vigano
Browse files

C++/mex another round of error throwing improvements

parent ddf5fc81
No related branches found
No related tags found
No related merge requests found
......@@ -190,7 +190,7 @@ namespace dct {
DctData<Type, Alloc>::set_dims(const TypeDims* init_dims, const size_t & num_dims, const size_t & skip_dims)
{
if (num_dims > 3) {
throw WrongArgumentException("Expected three dimensions for the initialization of Projection Data");
THROW(WrongArgumentException, DctData, "Expected three dimensions for the initialization of Projection Data");
}
for (size_t dim = 0; dim < num_dims; dim++) {
......@@ -238,7 +238,7 @@ namespace dct {
DctProjection<Type, Alloc>::set_dims(const std::vector<size_t> & new_dims)
{
if (new_dims.size() != 3) {
throw WrongArgumentException("Expected three dimensions for the initialization of Projection Data");
THROW(WrongArgumentException, DctProjection, "Expected three dimensions for the initialization of Projection Data");
}
DctData<Type, Alloc>::set_dims(new_dims);
......@@ -252,7 +252,7 @@ namespace dct {
DctProjection<Type, Alloc>::set_dims(const TypeDims * init_dims, const size_t & num_dims, const size_t & skip_dims)
{
if (num_dims != 3) {
throw WrongArgumentException("Expected three dimensions for the initialization of Projection Data");
THROW(WrongArgumentException, DctProjection, "Expected three dimensions for the initialization of Projection Data");
}
DctData<Type, Alloc>::set_dims(init_dims, num_dims, skip_dims);
......@@ -268,13 +268,13 @@ namespace dct {
DctProjectionVector<Type, Alloc>::check_consistency() const
{
if (this->empty()) {
throw WrongArgumentException("DctProjectionVector is empty! Cannot call consistency check!");
THROW(WrongArgumentException, DctProjectionVector, "DctProjectionVector is empty! Cannot call consistency check!");
}
const size_t * first_dims = (*this)[0].get_dims();
for (size_t num = 1; num < this->size(); num++) {
const size_t * current_dims = (*this)[num].get_dims();
if (first_dims[0] != current_dims[0] || first_dims[2] != current_dims[2]) {
throw WrongArgumentException("All the sinograms/blobs should have the same sizes along the first and third dimension");
THROW(WrongArgumentException, DctProjectionVector, "All the sinograms/blobs should have the same sizes along the first and third dimension");
}
}
}
......@@ -310,13 +310,13 @@ namespace dct {
DctVolumeGrid<Type, Alloc>::check_consistency() const
{
if (this->empty()) {
throw WrongArgumentException("DctVolumeGrid: no volumes stored! Cannot call consistency check!");
THROW(WrongArgumentException, DctVolumeGrid, "no volumes stored! Cannot call consistency check!");
}
const size_t * first_dims = (*this)[0].get_dims();
for (size_t num = 1; num < this->size(); num++) {
const size_t * current_dims = (*this)[num].get_dims();
if (first_dims != current_dims) {
throw WrongArgumentException("DctVolumeGrid: all volumes should have the same dimensions");
THROW(WrongArgumentException, DctVolumeGrid, "all volumes should have the same dimensions");
}
}
}
......@@ -346,7 +346,7 @@ namespace dct {
switch (reshape_policy) {
case ReshapePolicy::NoMatchThrowError:
{
throw WrongArgumentException("DctVolumeGrid: Requested reshape of wrong total number of elements");
THROW(WrongArgumentException, DctVolumeGrid, "Requested reshape of wrong total number of elements");
}
case ReshapePolicy::NoMatchClear:
{
......@@ -369,7 +369,7 @@ namespace dct {
switch (reshape_policy) {
case ReshapePolicy::NoMatchThrowError:
{
throw WrongArgumentException("DctVolumeGrid: assigned wrong total number of elements");
THROW(WrongArgumentException, DctVolumeGrid, "assigned wrong total number of elements");
}
case ReshapePolicy::NoMatchClear:
{
......@@ -428,10 +428,10 @@ namespace dct {
DctVolumeGrid<Type, Alloc>::sub_to_ind(const std::vector<size_t> & subs) const
{
if (subs.size() != this->grid_dims.size()) {
throw WrongArgumentException("DctVolumeGrid: requested volume position has a wrong dimensionality");
THROW(WrongArgumentException, DctVolumeGrid, "requested volume position has a wrong dimensionality");
}
if (subs.empty()) {
throw WrongArgumentException("DctVolumeGrid: requested volume position is empty");
THROW(WrongArgumentException, DctVolumeGrid, "requested volume position is empty");
}
size_t dim_mult = 1;
......@@ -440,7 +440,7 @@ namespace dct {
for (size_t dim = 1; dim < subs.size(); dim++)
{
if (subs[dim] > grid_dims[dim]) {
throw WrongArgumentException("DctVolumeGrid: requested volume position outside the grid limits");
THROW(WrongArgumentException, DctVolumeGrid, "requested volume position outside the grid limits");
}
dim_mult *= grid_dims[dim-1];
......@@ -457,10 +457,10 @@ namespace dct {
std::vector<size_t> inds;
if (ext_dim >= this->grid_dims.size()) {
throw WrongArgumentException("DctVolumeGrid: extended volumes dimension is bigger than the grid dimensions");
THROW(WrongArgumentException, DctVolumeGrid, "extended volumes dimension is bigger than the grid dimensions");
}
if (ext_dim < 0) {
throw WrongArgumentException("DctVolumeGrid: extended volumes dimension is less than 0");
THROW(WrongArgumentException, DctVolumeGrid, "extended volumes dimension is less than 0");
}
inds.resize(ext_inds.size());
......@@ -484,10 +484,10 @@ namespace dct {
std::vector<size_t> subs;
if (ind >= this->get_tot_vols()) {
throw WrongArgumentException("DctVolumeGrid: requested volume position is higher than the number of volumes");
THROW(WrongArgumentException, DctVolumeGrid, "requested volume position is higher than the number of volumes");
}
if (ind < 0) {
throw WrongArgumentException("DctVolumeGrid: requested volume position is less than 0");
THROW(WrongArgumentException, DctVolumeGrid, "requested volume position is less than 0");
}
subs.resize(grid_dims.size());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment