1

When testing with truffle and testrpc, I'm struggling to test how things should work when a function is called and it causes a throw as the entire test stops. However, several of the functions I have that return throws could also just do nothing. Is this the better structure? Basically, which is better:

function doSomethingThrow(a1) {
    if (a1.a == 1){
      ...
    } else if (a1.b == 2) {
      ...
    } else {
      throw;
    }

or

function doSomethingDontThrow(a1) {
    if (a1.a == 1){
      ...
    } else if (a1.b == 2) {
      ...
    }
1
  • Upvoted, but I think is a duplicate and additional answers in the same spot would be helpful for people. – eth Mar 29 '17 at 17:55