[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master de67a28 5/8: Improve an error message
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master de67a28 5/8: Improve an error message |
Date: |
Sat, 20 Mar 2021 09:55:30 -0400 (EDT) |
branch: master
commit de67a28b2623ee429f9dfa34b1c0ee62e1429b4c
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Improve an error message
State the arguments' lengths instead of just saying that they're
nonconformable.
Incidentally removed an unused parameter name.
---
et_vector_test.cpp | 3 ++-
tools/pete-2.1.1/et_vector.hpp | 11 +++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/et_vector_test.cpp b/et_vector_test.cpp
index 4e67020..3050703 100644
--- a/et_vector_test.cpp
+++ b/et_vector_test.cpp
@@ -50,7 +50,8 @@ int test_main(int, char*[])
{
std::vector<double> v0 = {0.0, 1.25, 2.5};
std::vector<double> v1 = {0.0, 1.25, 2.5, 3.75};
- LMI_TEST_THROW(v0 *= v1, std::runtime_error, "");
+ char const* s {"Nonconformable lengths: 3 lhs vs. 4 rhs."};
+ LMI_TEST_THROW(v0 *= v1, std::runtime_error, s);
}
// Test peteCast().
diff --git a/tools/pete-2.1.1/et_vector.hpp b/tools/pete-2.1.1/et_vector.hpp
index 3bb6f05..88147a5 100644
--- a/tools/pete-2.1.1/et_vector.hpp
+++ b/tools/pete-2.1.1/et_vector.hpp
@@ -56,6 +56,7 @@
#include "PETE/PETE.h"
+#include <sstream>
#include <stdexcept>
#include <vector>
@@ -148,7 +149,7 @@ template<typename T>
struct LeafFunctor<T, LengthLeaf>
{
typedef int Type_t;
- static Type_t apply(T const& a, LengthLeaf const&)
+ static Type_t apply(T const&, LengthLeaf const&)
{return 0;}
};
@@ -182,7 +183,13 @@ inline void evaluate(std::vector<T>& t, Op const& op,
Expression<U> const& u)
{
if(!forEach(u, SizeLeaf(lmi::ssize(t)), AndCombine()))
{
- throw std::runtime_error("Error: LHS and RHS don't conform.");
+ std::ostringstream oss;
+ oss
+ << "Nonconformable lengths: "
+ << lmi::ssize(t) << " lhs vs. "
+ << Rho(u) << " rhs."
+ ;
+ throw std::runtime_error(oss.str());
}
for(int i = 0; i < lmi::ssize(t); ++i)
- [lmi-commits] [lmi] master updated (1be41b7 -> 1d15a4a), Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master d5f870a 1/8: Improve documentation, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 4220f5e 2/8: Assume default allocator always, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 44b780e 7/8: Deduce Eval()'s return type, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master de67a28 5/8: Improve an error message,
Greg Chicares <=
- [lmi-commits] [lmi] master cd6c9ea 3/8: Favor the One True type-parameter-key, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 4c4a0e4 4/8: Add a PETE length-of function, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 1d15a4a 8/8: Isolate PETE directory weirdness to a redirection header, Greg Chicares, 2021/03/20
- [lmi-commits] [lmi] master 334ac64 6/8: Add a function template to transform a PETE expression to a std::vector, Greg Chicares, 2021/03/20