Pattern for rich error handling in gRPC : <p>What is the pattern for sending more details about errors to the client using gRPC?</p>

<p>For example, suppose I have a form for registering a user, that sends a message</p>

<pre><code>message RegisterUser {
  string email = 1;
  string password = 2;
}
</code></pre>

<p>where the email has to be properly formatted and unique, and the password must be at least 8 characters long.</p>

<p>If I was writing a JSON API, I'd return a 400 error with the following body:</p>

<pre><code>{
  "errors": [{
    "field": "email",
    "message": "Email does not have proper format."
   }, {
     "field": "password",
     "message": "Password must be at least 8 characters."
   }],
}
</code></pre>

<p>and the client could provide nice error messages to the user (i.e. by highlighting the password field and specifically telling the user that there's something wrong with their input to it).</p>

<p>With gRPC is there a way to do something similar? It seems that in most client languages, an error results in an exception being thrown, with no way to grab the response.</p>

<p>For example, I'd like something like</p>

<pre><code>message ValidationError {
  string field = 1;
  string message = 2;
}

message RegisterUserResponse {
  repeated ValidationError validation_errors = 1;
  ...
}
</code></pre>

<p>or similar.</p>
