Commits

wlav  committed 6c98c84

really pretty error messages

  • Participants
  • Parent commits 97fa84a
  • Branches reflex-support

Comments (0)

Files changed (2)

File pypy/module/cppyy/interp_cppyy.py

                 pass
 
         # only get here if all overloads failed ...
-        errmsg = 'None of the overloads matched:'
+        errmsg = 'none of the %d overloaded methods succeeded. Full details:' % len(self.functions)
         if hasattr(self.space, "fake"):     # FakeSpace fails errorstr (see below)
             raise OperationError(self.space.w_TypeError, self.space.wrap(errmsg))
         for i in range(len(self.functions)):
             try:
                 return cppyyfunc.call(cppthis, args_w)
             except OperationError, e:
-                errmsg += '\n\t'+e.errorstr(self.space)
+                errmsg += '\n  '+cppyyfunc.signature()+' =>\n'
+                errmsg += '    '+e.errorstr(self.space)
             except Exception, e:
-                errmsg += '\n\tException:'+str(e)
+                errmsg += '\n  '+cppyyfunc.signature()+' =>\n'
+                errmsg += '    Exception:'+str(e)
 
         raise OperationError(self.space.w_TypeError, self.space.wrap(errmsg))
 

File pypy/module/cppyy/test/test_fragile.py

             d.check(None)         # raises TypeError
             assert 0
         except TypeError, e:
+            assert "fragile::D::check()" in str(e)
             assert "TypeError: wrong number of arguments" in str(e)
 
+        try:
+            d.overload(None)      # raises TypeError
+            assert 0
+        except TypeError, e:
+            assert "fragile::D::overload()" in str(e)
+            assert "TypeError: wrong number of arguments" in str(e)
+            assert "fragile::D::overload(fragile::no_such_class*)" in str(e)
+            assert "TypeError: no converter available for type \"fragile::no_such_class*\"" in str(e)
+            assert "fragile::D::overload(char, int)" in str(e)
+            assert "TypeError: expected string, got NoneType object" in str(e)
+            assert "fragile::D::overload(int, fragile::no_such_class*)" in str(e)
+            assert "TypeError: unsupported operand type for int(): 'NoneType'" in str(e)
+
         j = fragile.J()
         assert fragile.J.method1.__doc__ == j.method1.__doc__
         assert j.method1.__doc__ == "fragile::J::method1(int, double)"