public class

ServiceErrors

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

Class Overview

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.

Summary

Fields
private static final ContentType DEFAULT_CONTENT_TYPE
private List<ServiceError> dataErrors Errors with type = data.
private List<ServiceError> requestErrors Errors with type != data.
Public Constructors
ServiceErrors(ServiceException e)
Creates a ServiceErrors object corresponding to the errors contained in a ServiceException.
ServiceErrors(BatchStatus status)
Creates a ServiceErrors object corresponding to the errors contained in BatchStatus.
ServiceErrors()
Empty constructor.
Public Methods
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.
List<? extends ServiceError> getAllErrors()
Gets all errors.
Collection<? extends ServiceError> getDataErrors()
Gets data errors, which apply to the item content, often to one field in particular.
Set<? extends String> getErrorFields()
Gets the set of all fields that have errors.
List<? extends ServiceError> getFieldErrors(String field)
Gets all errors for one specific field.
List<? extends ServiceError> getRequestErrors()
Gets non-data errors, which apply to the whole request.
String toString()
Returns a convenient text representation, for debugging.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private static final ContentType DEFAULT_CONTENT_TYPE

private List<ServiceError> dataErrors

Errors with type = data.

private List<ServiceError> requestErrors

Errors with type != data.

Public Constructors

public ServiceErrors (ServiceException e)

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

Parameters
e

public ServiceErrors (BatchStatus status)

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

Parameters
status

public ServiceErrors ()

Empty constructor.

Public Methods

public void addError (ServiceError error)

Registers a new error.

Parameters
error

public void addErrors (BatchStatus status)

Extracts errors from a BatchStatus.

Parameters
status The BatchStatus to be parsed

public void addErrors (ServiceException e)

Extracts errors from a ServiceException.

Parameters
e The ServiceException to be parsed

public List<? extends ServiceError> getAllErrors ()

Gets all errors.

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

public 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.

public Set<? extends String> getErrorFields ()

Gets the set of all fields that have errors.

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

public List<? extends ServiceError> getFieldErrors (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.

public List<? extends ServiceError> getRequestErrors ()

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

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

public String toString ()

Returns a convenient text representation, for debugging.