Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / search / StatusCode.java
blobcbbfd6c6a90bc1101868e572c203d216b04cc59a
1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com.google.appengine.api.search;
5 import com.google.appengine.api.search.SearchServicePb.SearchServiceError.ErrorCode;
7 /**
8 * Status code returned by various index operations.
9 */
10 public enum StatusCode {
11 /**
12 * The last operation was successfully completed.
14 OK,
16 /**
17 * The last operation failed due to invalid, user specified parameters.
19 INVALID_REQUEST,
21 /**
22 * The last operation failed due to a transient backend error.
24 TRANSIENT_ERROR,
26 /**
27 * The last operation failed due to a internal backend error.
29 INTERNAL_ERROR,
31 /**
32 * The last operation failed due to user not having permission.
34 PERMISSION_DENIED_ERROR;
36 /**
37 * Provides a mapping from protocol buffer enum to user API enum.
39 * @param code the proto buffer enum
40 * @return the corresponding user API enum
42 static StatusCode fromErrorCode(ErrorCode code) {
43 switch (code) {
44 case OK: return StatusCode.OK;
45 case INVALID_REQUEST: return StatusCode.INVALID_REQUEST;
46 case TRANSIENT_ERROR: return StatusCode.TRANSIENT_ERROR;
47 case INTERNAL_ERROR: return StatusCode.INTERNAL_ERROR;
48 case PERMISSION_DENIED: return StatusCode.PERMISSION_DENIED_ERROR;
50 throw new IllegalArgumentException("Failed to convert error code to status enum " + code);