code: func buildJSONError(err error) *JSONError {
  	jsonError := &JSONError{
  		Code:    UnknownErrorCode,
  		Message: "Something went wrong",
  	}
  	if err == ErrRequestBodyTooBig {
  		return &JSONError{
  			Code:    RequestBodyTooBigErrorCode,
  			Message: "The provided request body is too big",
  		}
  	}
  	switch v := err.(type) {
  	case *json.SyntaxError, *json.UnmarshalTypeError:
  		jsonError = &JSONError{
  			Code:    SyntaxErrorCode,
  			Message: "The provided JSON input is invalid",
  		}
  	case pgx.PgError, *net.OpError, syscall.Errno:
  		jsonError.Retry = true
  	case JSONError:
  		jsonError = &v
  	case *JSONError:
  		jsonError = v
  	default:
  		if err == pgx.ErrDeadConn {
  			jsonError.Retry = true
  		}
  	}
  	return jsonError
  }
docs: // buildJSONError returns an appropriate API error to send to clients based
  // on the given internal error.
  //
  // We consider all postgres errors as retry-able as they usually occur when
  // postgres is read-only (for example during a system update). Data related
  // postgres errors should in general not be retried (because a retry will
  // likely result in the same error), but it is expected that such errors are
  // caught and a validation error returned to the client rather than the
  // postgres error.
  //
  // Errors returned from "net" are also considered retryable because they
  // generally occur when the process is trying to reach another resource which
  // may be down temporarily.
  // This also includes syscall.Errno, which is notable because it can also be
  // returned from file operations among other things.
  // It's expected if you don't want clients to retry on these errors they
  // should be caught and a more appropriate error returned to the caller.