title: Bind errors on Spring MVC Controller and put in a BindingResult
body: <p>When I try to do a "bind" in my class, it throws an exception, but how can I show an error on the form?</p>
  
  <p>Controller:</p>
  
  <pre><code>@InitBinder
  public final void binder(WebDataBinder binder) {        
      binder.registerCustomEditor(Telefone.class, new PropertyEditorSupport(){
  
          @Override
          public void setAsText(String value){
              if(null != value){
                  try{
                      setValue(Telefone.fromString(value));
                  } catch (IllegalArgumentException e) {
                      // what to do here ??
                  }
              }
          }
  
      });
  </code></pre>
  
  <p><a href="https://github.com/insula/opes/blob/master/src/main/java/br/com/insula/opes/Telefone.java" rel="nofollow">Phone</a>:</p>
  
  <pre><code>public static Telefone fromString(String s) {
      checkNotNull(s);
      String digits = s.replaceAll("\\D", "");
      checkArgument(digits.matches("1\\d{2}|1\\d{4}|0300\\d{8}|0800\\d{7,8}|\\d{8,13}"));
      return new Telefone(digits);
  }
  </code></pre>
  
  <p><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Preconditions.html#checkArgument%28boolean%29" rel="nofollow">chekArgument is from Google Preconditions</a></p>
  
  <p>When phone is not valid, an IllegalArgumentException is thrown .. but how to put it in a BindingResult</p>