Skip to content

Commit

Permalink
#2673 Catch exception by reference (SonarQubue)
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Oct 19, 2023
1 parent 723bff8 commit 65e2fef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/libcode/vx_nc_util/nc_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

////////////////////////////////////////////////////////////////////////

using namespace std;

#include <string.h>
#include <cstring>
#include <sys/stat.h>

#include <netcdf>
using namespace netCDF;
using namespace netCDF::exceptions;

#include "vx_log.h"
#include "nc_utils.h"
#include "util_constants.h"
#include "vx_cal.h"

using namespace std;
using namespace netCDF;
using namespace netCDF::exceptions;

////////////////////////////////////////////////////////////////////////

void patch_nc_name(string *var_name) {
Expand Down Expand Up @@ -172,7 +172,7 @@ bool get_att_value_chars(const NcAtt *att, ConcatString &value) {
att->getValues(att_value);
value = att_value;
}
catch (exceptions::NcChar ex) {
catch (exceptions::NcChar &ex) {
value = "";
// Handle netCDF::exceptions::NcChar: NetCDF: Attempt to convert between text & numbers
mlog << Warning << "\n" << method_name
Expand All @@ -188,7 +188,7 @@ bool get_att_value_chars(const NcAtt *att, ConcatString &value) {
att->getValues(att_value);
value = att_value;
}
catch (exceptions::NcChar ex) {
catch (exceptions::NcChar &ex) {
int num_elements_sub = 8096;
int num_elements = att->getAttLength();;
char *att_value[num_elements];
Expand All @@ -199,7 +199,7 @@ bool get_att_value_chars(const NcAtt *att, ConcatString &value) {
att->getValues(att_value);
value = att_value[0];
}
catch (exceptions::NcException ex) {
catch (exceptions::NcException &ex) {
mlog << Warning << "\n" << method_name
<< "Exception: " << ex.what() << "\n"
<< "Fail to read " << GET_NC_NAME_P(att) << " attribute ("
Expand Down

0 comments on commit 65e2fef

Please sign in to comment.