title: Grail: Error handling in @BindUsing
body: <p>I have tried to use @BindUsing for a property (amt100) of a domain class (TcTransaction). The purpose is to convert a display format to a database format. Out of a dozen variants, here is one:</p>
  
  <pre><code>@BindUsing({tcTransaction, source -&gt;
    def result = tcTransaction.amt100
    def amt = Amount100.of(source['amt100']) //parse and convert input
    if (amt) {
      result = amt.cents
    } else {
      tcTransaction.errors.rejectValue('amt100', 'tcTransaction.invalid.amount')
    }
    return result
        })
  Integer amt100
  </code></pre>
  
  <p>It works beautifully in the absence of errors. The problem is error management. This particular version returns the original value if the new value is invalid. It also adds an error to the domain object.</p>
  
  <p>It seems adding to errors has no effect. The user is not warned.</p>
  
  <p>I also tried to throw an exception. It seems whatever exception you throw you end up with a standard error code saying that the property must not be left empty. A <a href="https://stackoverflow.com/questions/29253601/how-to-handle-errors-that-occur-in-bindusing-annotation-closure">previous post</a> indicated this behaviour. (It has gone unanswered for two years.) I'm on Grails 3.2.8.</p>
  
  <p>So, is there any theory of error management in @BindUsing? It's such a nifty mechanism.</p>