diff --git a/shared/lib_irradproc.cpp b/shared/lib_irradproc.cpp index 21cffe5fd..785dda003 100644 --- a/shared/lib_irradproc.cpp +++ b/shared/lib_irradproc.cpp @@ -1842,56 +1842,56 @@ irrad::irrad(weather_header hdr, } int irrad::check() { - if (year < 0 || month < 0 || day < 0 || hour < 0 || minute < 0 || delt > 1) { - errorMessage = "Invalid year, month, hour, or minute data"; + if (year < 0 || month < 0 || day < 0 || hour < 0 || minute < 0 || delt > 1 ) { + errorMessage = util::format("Invalid year (%d), month (%d), hour (%d), minute (%d) data, or invalid time step (%lg) hours", year, month, day, hour, minute, delt); return -1; } if (latitudeDegrees < -90 || latitudeDegrees > 90 || longitudeDegrees < -180 || longitudeDegrees > 180 || timezone < -15 || timezone > 15) { - errorMessage = "Invalid latitude, longitude, or time zone"; + errorMessage = util::format("Invalid latitude (%lg), longitude (%lg), or time zone (%lg), latitude must be between -90 and 90 degrees, longitude must be between -180 and 180 degrees, time zone must be between -15 and 15", latitudeDegrees, longitudeDegrees, timezone); return -2; } if (radiationMode < irrad::DN_DF || radiationMode > irrad::POA_P || skyModel < 0 || skyModel > 2) { - errorMessage = "Invalid radiation mode or sky model"; + errorMessage = util::format("Invalid radiation mode (%d) or sky model (%d)", radiationMode, skyModel); return -3; } if (trackingMode < 0 || trackingMode > 4) { - errorMessage = "Invalid tracking mode"; + errorMessage = util::format("Invalid tracking mode (%d)", trackingMode); return -4; } if (radiationMode == irrad::DN_DF && (directNormal < 0 || directNormal > irrad::irradiationMax || diffuseHorizontal < 0 || diffuseHorizontal > 1500)) { - errorMessage = "Invalid DNI or DHI (negative or out of bounds)"; + errorMessage = util::format("Invalid DNI (%lg) or DHI (%lg), DNI must be between 0 and %lg W/m2, DHI must be between 0 and 1500 W/m2", directNormal, diffuseHorizontal, irrad::irradiationMax); return -5; } if (radiationMode == irrad::DN_GH && (globalHorizontal < 0 || globalHorizontal > 1500 || directNormal < 0 || directNormal > 1500)) { - errorMessage = "Invalid GHI or DNI (negative or out of bounds)"; + errorMessage = util::format("Invalid DNI (%lg) or GHI (%lg), DNI must be between 0 and %lg W/m2, GHI must be between 0 and 1500 W/m2", directNormal, diffuseHorizontal, irrad::irradiationMax); return -6; } if (albedo < 0 || albedo > 1) { - errorMessage = "Invalid albedo, must be greater than 0 and no greater than 1"; + errorMessage = util::format("Invalid albedo (%lg), must be between 0 and 1", albedo); return -7; } if (tiltDegrees < 0 || tiltDegrees > 90) { - errorMessage = "Invalid tilt angle, must be greater than 0 and no greater than 90 degrees"; + errorMessage = util::format("Invalid tilt angle (%lg), must be between 0 and 90 degrees", tiltDegrees); return -8; } if (surfaceAzimuthDegrees < 0 || surfaceAzimuthDegrees >= 360) { - errorMessage = "Invalid azimuth, must be greater than 0 and less than 360 degrees"; + errorMessage = util::format("Invalid azimuth (%lg), must be between 0 and 360 degrees", surfaceAzimuthDegrees); return -9; } if (rotationLimitDegrees < -90 || rotationLimitDegrees > 90) { - errorMessage = "Invalid tracker rotation limit, must be greater than -90 and no greater than 90 degrees"; + errorMessage = util::format("Invalid tracker rotation limit (%lg), must be between -90 and 90 degrees", rotationLimitDegrees); return -10; } if (stowAngleDegrees < -90 || stowAngleDegrees > 90) { - errorMessage = "Invalid stow angle, must be greater than -90 and no greater than 90 degrees"; + errorMessage = util::format("Invalid stow angle (%lg), must be between -90 and 90 degrees", stowAngleDegrees); return -12; } if (radiationMode == irrad::GH_DF && (globalHorizontal < 0 || globalHorizontal > 1500 || diffuseHorizontal < 0 || diffuseHorizontal > 1500)) { - errorMessage = "Invalid GHI or DHI (negative or exceeds theoretical limit)"; + errorMessage = util::format("Invalid GHI (%lg) or DHI (%lg), must be between 0 and 1500 W/m2", globalHorizontal, diffuseHorizontal); return -11; } diff --git a/shared/lib_util.cpp b/shared/lib_util.cpp index 114e493c4..fa1c03bf3 100644 --- a/shared/lib_util.cpp +++ b/shared/lib_util.cpp @@ -932,20 +932,20 @@ size_t util::hour_of_year(size_t month, size_t day, size_t hour) h += days_in_months[m] * 24; } else - throw std::runtime_error(util::format("unable to determine hour of year (0-8759) because month is out of range for time stamp month-day-hour: %d-%d-%d", month, day, hour)); + throw std::runtime_error(util::format("unable to determine hour of year (0-8759) because month is out of range for time stamp (month-day-hour): %d-%d-%d", month, day, hour)); //then add days in the current month up to the current day if (day >= 1 && day <= days_in_months[month - 1]) h += (day - 1) * 24; else if (month == 2 && day == 29) //special check for leap day present in data h += (27 * 24); //for leap day, repeat Feb 28 in annual indexes, because hour_of_year is used to index 8760 non-leap-year arrays. else - throw std::runtime_error(util::format("unable to determine hour of year (0 - 8759) because day is out of range for time stamp month-day-hour: %d-%d-%d", month, day, hour)); + throw std::runtime_error(util::format("unable to determine hour of year (0 - 8759) because day is out of range for time stamp (month-day-hour): %d-%d-%d", month, day, hour)); if (hour >= 0 && hour <= 23) h += hour; else - throw std::runtime_error(util::format("unable to determine hour of year (0 - 8759) because hour is out of range for time stamp month-day-hour: %d-%d-%d", month, day, hour)); + throw std::runtime_error(util::format("unable to determine hour of year (0 - 8759) because hour is out of range for time stamp (month-day-hour): %d-%d-%d", month, day, hour)); if (hour > 8759) - throw std::runtime_error(util::format("unable to determine hour of year (0 - 8759) because hour is greater than 8759 for time stamp month-day-hour: %d-%d-%d", month, day, hour)); + throw std::runtime_error(util::format("unable to determine hour of year (0 - 8759) because hour is greater than 8759 for time stamp (month-day-hour): %d-%d-%d", month, day, hour)); return h; } diff --git a/ssc/cmod_irradproc.cpp b/ssc/cmod_irradproc.cpp index 4d3a7c2e0..ef4562d09 100644 --- a/ssc/cmod_irradproc.cpp +++ b/ssc/cmod_irradproc.cpp @@ -151,7 +151,7 @@ class cm_irradproc : public compute_module else { elev = as_double("elevation"); if (elev < 0 || elev > 5100) { - throw exec_error("irradproc", "The elevation input is outside of the expected range. Please make sure that the units are in meters"); + throw exec_error("irradproc", util::format("The elevation (%lg) must be between 0 and 5100 meters", elev)); } } if (!is_assigned("tamb")) { @@ -160,7 +160,7 @@ class cm_irradproc : public compute_module else { tamb = as_double("tamb"); if (tamb > 128 || tamb < -50) { - throw exec_error("irradproc", "The annual average temperature input is outside of the expected range. Please make sure that the units are in degrees Celsius"); + throw exec_error("irradproc", util::format("The ambient temperature (%lg) must be between -50 and 128 degrees Celsius", tamb)); } } if (!is_assigned("pressure")) { @@ -169,7 +169,7 @@ class cm_irradproc : public compute_module else { pres = as_double("pressure"); if (pres > 2000 || pres < 500) { - throw exec_error("irradproc", "The atmospheric pressure input is outside of the expected range. Please make sure that the units are in millibars"); + throw exec_error("irradproc", util::format("The atmospheric pressure (%lg) must be between 500 and 2000 millibars", pres)); } }