# Google Data APIs Client Library (1.43.0)

## com.google.api.gbase.client
Class ServiceErrors

    java.lang.Object
      com.google.api.gbase.client.ServiceErrors

    public class ServiceErrors

extends java.lang.Object

Extracts and organizes error messages from a `ServiceException` or from a `BatchStatus`. This object parses the body of a ServiceException or the content of a BatchStatus and gives programmatic access to the error messages embedded in the body of the exception.

Constructor Summary
`ServiceErrors()` Empty constructor.
`ServiceErrors(BatchStatus status)` Creates a ServiceErrors object corresponding to the errors contained in `BatchStatus`.
`ServiceErrors(ServiceException e)` Creates a ServiceErrors object corresponding to the errors contained in a `ServiceException`.

Method Summary
`void` `addError(ServiceError error)` Registers a new error.
`void` `addErrors(BatchStatus status)` Extracts errors from a `BatchStatus`.
`void` `addErrors(ServiceException e)` Extracts errors from a `ServiceException`.
`java.util.List<? extends ServiceError>` `getAllErrors()` Gets all errors.
`java.util.Collection<? extends ServiceError>` `getDataErrors()` Gets data errors, which apply to the item content, often to one field in particular.
`java.util.Set<? extends java.lang.String>` `getErrorFields()` Gets the set of all fields that have errors.
`java.util.List<? extends ServiceError>` `getFieldErrors(java.lang.String field)` Gets all errors for one specific field.
`java.util.List<? extends ServiceError>` `getRequestErrors()` Gets non-data errors, which apply to the whole request.
`java.lang.String` `toString()` Returns a convenient text representation, for debugging.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ServiceErrors

    public ServiceErrors(ServiceException e)

  Creates a ServiceErrors object corresponding to the errors contained in a `ServiceException`.

  Parameters:
    `e` -

### ServiceErrors

    public ServiceErrors(BatchStatus status)

  Creates a ServiceErrors object corresponding to the errors contained in `BatchStatus`.

  Parameters:
    `status` -

### ServiceErrors

    public ServiceErrors()

  Empty constructor.

Method Detail

### toString

    public java.lang.String toString()

  Returns a convenient text representation, for debugging.

  Overrides:
    `toString` in class `java.lang.Object`

### addErrors

    public void addErrors(ServiceException e)

  Extracts errors from a `ServiceException`.

  Parameters:
    `e` - the ServiceException to be parsed

### addErrors

    public void addErrors(BatchStatus status)

  Extracts errors from a `BatchStatus`.

  Parameters:
    `status` - the BatchStatus to be parsed

### addError

    public void addError(ServiceError error)

  Registers a new error.

  Parameters:
    `error` -

### getAllErrors

    public java.util.List<? extends ServiceError> getAllErrors()

  Gets all errors.

  Returns:
    both request and data errors. May be empty but not null.

### getRequestErrors

    public java.util.List<? extends ServiceError> getRequestErrors()

  Gets non-data errors, which apply to the whole request.

  Returns:
    non-data errors. May be empty but not null.

### getDataErrors

    public java.util.Collection<? extends ServiceError> getDataErrors()

  Gets data errors, which apply to the item content, often to one field in particular.

  Returns:
    data errors. May be empty but not null.

### getErrorFields

    public java.util.Set<? extends java.lang.String> getErrorFields()

  Gets the set of all fields that have errors.

  Returns:
    field names. May be empty but not null.

### getFieldErrors

    public java.util.List<? extends ServiceError> getFieldErrors(java.lang.String field)

  Gets all errors for one specific field.

  Parameters:
    `field` - field name, which usually comes from `getErrorFields()`
  Returns:
    all errors applied to the field. May be empty but not null.