Converts AWS error code to dasein cloud error type

@param code AWS error code
@return dasein cloud error type
175764
private static CloudErrorType toCloudErrorType(String code) {
        if ("Throttling".equals(code)) {
            return CloudErrorType.THROTTLING;
        } else if ("TooManyBuckets".equals(code)) {
            return CloudErrorType.QUOTA;
        } else if ("SignatureDoesNotMatch".equals(code)) {
            return CloudErrorType.AUTHENTICATION;
        } else {
            return CloudErrorType.GENERAL;
        }
    }
941313
private static int decodeBase31(@Nonnull final String code) {
        int value = 0;
        for (final char c : code.toCharArray()) {
            if (c == '.') {
                return value;
            }
            if (DECODE_CHARS[c] < 0) {
                return -1;
            }
            value = (value * 31) + DECODE_CHARS[c];
        }
        return value;
    }
119667
protected ParsingError error( ErrorCode errorCode, ErrorDetails... details ) {
		return new ParsingError(
				errorCode,
				this.context.getCommandFile(),
				this.line,
				details );
	}
720894
function getError(number, countryCode) {
    try {
        var phoneUtil = i18n.phonenumbers.PhoneNumberUtil.getInstance();
        var numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
        return phoneUtil.isPossibleNumberWithReason(numberObj);
    } catch (e) {
        //console.log(e);

        // here I convert thrown errors into ValidationResult enums (if possible)
        if (e == i18n.phonenumbers.Error.INVALID_COUNTRY_CODE) {
            return i18n.phonenumbers.PhoneNumberUtil.ValidationResult.INVALID_COUNTRY_CODE;
        }
        if (e == i18n.phonenumbers.Error.NOT_A_NUMBER) {
            return 4;
        }
        if (e == i18n.phonenumbers.Error.TOO_SHORT_AFTER_IDD || e == i18n.phonenumbers.Error.TOO_SHORT_NSN) {
            return i18n.phonenumbers.PhoneNumberUtil.ValidationResult.TOO_SHORT;
        }
        if (e == i18n.phonenumbers.Error.TOO_LONG) {
            return i18n.phonenumbers.PhoneNumberUtil.ValidationResult.TOO_LONG;
        }

        // broken
        return -99;
    }
}
708073
public static function errorToException($code){
    if(!isset(self::$codeMap[$code])){
      return new BadResponseException(sprintf(
        'Undefined error code "%s"',
        $code
      ));
    }
    $exceptionClass = self::$codeMap[$code];
    return  new $exceptionClass;
  }
557813
def error_code(self, code):
		
		return WWebResponse(
			status=code,
			headers=WHTTPHeaders(**{'Content-Type': 'text/plain; charset=utf-8'}),
			response_data=self.__message__(code).encode()
		)
12820
public static String getMessage(int code)
    {
        Code codeEnum = getCode(code);
        if (codeEnum != null)
        {
            return codeEnum.getMessage();
        }
        else
        {
            return Integer.toString(code);
        }
    }
193458
public OauthGetTokenResponse getToken(String code) {
        BeanUtil.requireNonNull(code, "code is null");
        OauthGetTokenResponse response = null;
        String url = BASE_API_URL + "sns/oauth2/access_token?appid=" + this.config.getAppid() + "&secret=" + this.config.getSecret() + "&code=" + code + "&grant_type=authorization_code";
        BaseResponse r = executeGet(url);
        String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString();
        response = JSONUtil.toBean(resultJson, OauthGetTokenResponse.class);
        return response;
    }
434111
function createError(code, type, desc) {
	errors[code] = function (msg, meta) {
		const err = new type(msg);

		if (desc) {
			if (!meta) {
				meta = {};
			}
			meta.desc = desc;
		}

		return Object.defineProperties(err, {
			code: {
				configurable: true,
				enumerable: true,
				writable: true,
				value: `ERR_${code}`
			},
			meta: {
				configurable: true,
				value: meta || undefined,
				writable: true
			}
		});
	};

	Object.defineProperties(errors[code], {
		name: {
			configurable: true,
			value: code,
			writable: true
		},
		toString: {
			configurable: true,
			value: function toString() {
				return `ERR_${code}`;
			},
			writable: true
		}
	});
}
1102313
public static ResponseStatus fromBinary(final short code) {
        KeyValueStatus status = KeyValueStatus.valueOf(code);
        switch (status) {
            case SUCCESS:
                return ResponseStatus.SUCCESS;
            case ERR_EXISTS:
                return ResponseStatus.EXISTS;
            case ERR_NOT_FOUND:
                return ResponseStatus.NOT_EXISTS;
            case ERR_NOT_MY_VBUCKET:
                return ResponseStatus.RETRY;
            case ERR_NOT_STORED:
                return ResponseStatus.NOT_STORED;
            case ERR_TOO_BIG:
                return ResponseStatus.TOO_BIG;
            case ERR_TEMP_FAIL:
                return ResponseStatus.TEMPORARY_FAILURE;
            case ERR_BUSY:
                return ResponseStatus.SERVER_BUSY;
            case ERR_NO_MEM:
                return ResponseStatus.OUT_OF_MEMORY;
            case ERR_UNKNOWN_COMMAND:
                return ResponseStatus.COMMAND_UNAVAILABLE;
            case ERR_NOT_SUPPORTED:
                return ResponseStatus.COMMAND_UNAVAILABLE;
            case ERR_ACCESS:
                return ResponseStatus.ACCESS_ERROR;
            case ERR_INTERNAL:
                return ResponseStatus.INTERNAL_ERROR;
            case ERR_INVALID:
                return ResponseStatus.INVALID_ARGUMENTS;
            case ERR_DELTA_BADVAL:
                return ResponseStatus.INVALID_ARGUMENTS;
            case ERR_RANGE:
                return ResponseStatus.RANGE_ERROR;
            case ERR_ROLLBACK:
                return ResponseStatus.ROLLBACK;
            //== the following codes are for subdocument API ==
            case ERR_SUBDOC_PATH_NOT_FOUND:
                return ResponseStatus.SUBDOC_PATH_NOT_FOUND;
            case ERR_SUBDOC_PATH_MISMATCH:
                return ResponseStatus.SUBDOC_PATH_MISMATCH;
            case ERR_SUBDOC_PATH_INVALID:
                return ResponseStatus.SUBDOC_PATH_INVALID;
            case ERR_SUBDOC_PATH_TOO_BIG:
                return ResponseStatus.SUBDOC_PATH_TOO_BIG;
            case ERR_SUBDOC_DOC_TOO_DEEP:
                return ResponseStatus.SUBDOC_DOC_TOO_DEEP;
            case ERR_SUBDOC_VALUE_CANTINSERT:
                return ResponseStatus.SUBDOC_VALUE_CANTINSERT;
            case ERR_SUBDOC_DOC_NOT_JSON:
                return ResponseStatus.SUBDOC_DOC_NOT_JSON;
            case ERR_SUBDOC_NUM_RANGE:
                return ResponseStatus.SUBDOC_NUM_RANGE;
            case ERR_SUBDOC_DELTA_RANGE:
                return ResponseStatus.SUBDOC_DELTA_RANGE;
            case ERR_SUBDOC_PATH_EXISTS:
                return ResponseStatus.SUBDOC_PATH_EXISTS;
            case ERR_SUBDOC_VALUE_TOO_DEEP:
                return ResponseStatus.SUBDOC_VALUE_TOO_DEEP;
            case ERR_SUBDOC_INVALID_COMBO:
                return ResponseStatus.SUBDOC_INVALID_COMBO;
            case ERR_SUBDOC_MULTI_PATH_FAILURE:
                return ResponseStatus.SUBDOC_MULTI_PATH_FAILURE;
            case ERR_SUBDOC_XATTR_INVALID_FLAG_COMBO:
                return ResponseStatus.INTERNAL_ERROR;
            case ERR_SUBDOC_XATTR_UNKNOWN_MACRO:
                return ResponseStatus.SUBDOC_XATTR_UNKNOWN_MACRO;
            case ERR_SUBDOC_XATTR_INVALID_KEY_COMBO:
                return ResponseStatus.SUBDOC_XATTR_INVALID_KEY_COMBO;
            //== end of subdocument API codes ==
        }
        return ResponseStatus.FAILURE;
    }
1300196
public OvhSOTPValidate accessRestriction_backupCode_validate_POST(String code) throws IOException {
		String qPath = "/me/accessRestriction/backupCode/validate";
		StringBuilder sb = path(qPath);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "code", code);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhSOTPValidate.class);
	}
1056481
public MAPErrorMessage createMessageFromErrorCode(Long errorCode) {
        long ec = (long) errorCode;
        switch ((int) ec) {
            case MAPErrorCode.unexpectedDataValue:
            case MAPErrorCode.dataMissing:
            case MAPErrorCode.unidentifiedSubscriber:
            case MAPErrorCode.illegalSubscriber:
            case MAPErrorCode.illegalEquipment:
            case MAPErrorCode.teleserviceNotProvisioned:
            case MAPErrorCode.messageWaitingListFull:
            case MAPErrorCode.unauthorizedRequestingNetwork:
            case MAPErrorCode.resourceLimitation:
            case MAPErrorCode.unknownOrUnreachableLCSClient:
            case MAPErrorCode.incompatibleTerminal:
            case MAPErrorCode.noRoamingNumberAvailable:
            case MAPErrorCode.noSubscriberReply:
            case MAPErrorCode.forwardingFailed:
            case MAPErrorCode.orNotAllowed:
            case MAPErrorCode.forwardingViolation:
            case MAPErrorCode.numberChanged:
            case MAPErrorCode.unknownMSC:
            case MAPErrorCode.unknownEquipment:
            case MAPErrorCode.bearerServiceNotProvisioned:
            case MAPErrorCode.mmEventNotSupported:
            case MAPErrorCode.illegalSSOperation:
            case MAPErrorCode.ssNotAvailable:
            case MAPErrorCode.ssSubscriptionViolation:
            case MAPErrorCode.unknownAlphabet:
            case MAPErrorCode.ussdBusy:
            case MAPErrorCode.negativePWCheck:
            case MAPErrorCode.numberOfPWAttemptsViolation:
            case MAPErrorCode.shortTermDenial:
            case MAPErrorCode.longTermDenial:
                return new MAPErrorMessageExtensionContainerImpl(errorCode);

            case MAPErrorCode.smDeliveryFailure:
                return new MAPErrorMessageSMDeliveryFailureImpl();

            case MAPErrorCode.absentSubscriberSM:
                return new MAPErrorMessageAbsentSubscriberSMImpl();

            case MAPErrorCode.systemFailure:
                return new MAPErrorMessageSystemFailureImpl();

            case MAPErrorCode.callBarred:
                return new MAPErrorMessageCallBarredImpl();

            case MAPErrorCode.facilityNotSupported:
                return new MAPErrorMessageFacilityNotSupImpl();

            case MAPErrorCode.unknownSubscriber:
                return new MAPErrorMessageUnknownSubscriberImpl();

            case MAPErrorCode.subscriberBusyForMTSMS:
                return new MAPErrorMessageSubscriberBusyForMtSmsImpl();

            case MAPErrorCode.absentSubscriber:
                return new MAPErrorMessageAbsentSubscriberImpl();

            case MAPErrorCode.unauthorizedLCSClient:
                return new MAPErrorMessageUnauthorizedLCSClientImpl();

            case MAPErrorCode.positionMethodFailure:
                return new MAPErrorMessagePositionMethodFailureImpl();

            case MAPErrorCode.busySubscriber:
                return new MAPErrorMessageBusySubscriberImpl();

            case MAPErrorCode.cugReject:
                return new MAPErrorMessageCUGRejectImpl();

            case MAPErrorCode.roamingNotAllowed:
                return new MAPErrorMessageRoamingNotAllowedImpl();

            case MAPErrorCode.ssErrorStatus:
                return new MAPErrorMessageSsErrorStatusImpl();

            case MAPErrorCode.ssIncompatibility:
                return new MAPErrorMessageSsIncompatibilityImpl();

            case MAPErrorCode.pwRegistrationFailure:
                return new MAPErrorMessagePwRegistrationFailureImpl();

            default:
                return new MAPErrorMessageParameterlessImpl(errorCode);
        }

    }
802749
protected function buildErrorResponse($error, $code = null)
    {
        if ($code !== null && (!is_int($code) || $code < 400)) {
            $code = null;
        }
        if (is_object($error)) {
            if ($error instanceof AccessDeniedException) {
                $error = $error->getMessage();
                if ($code === null) {
                    $code = Response::HTTP_UNAUTHORIZED;
                }
            } elseif ($error instanceof UserMessageException) {
                if ($error->getCode() >= 400) {
                    $code = $error->getCode();
                }
                $error = $error->getMessage();
            } elseif ($error instanceof Exception || $error instanceof Throwable) {
                $error = t('An unexpected error occurred');
            } elseif (is_callable([$error, '__toString'])) {
                $error = (string) $error;
            } else {
                $error = get_class($error);
            }
        }
        if ($code === null) {
            $code = Response::HTTP_INTERNAL_SERVER_ERROR;
        }

        return $this->getResponseFactory()->create(
            $error,
            $code,
            [
                'Content-Type' => 'text/plain; charset=UTF-8',
            ]
        );
    }
536434
public static JsonObjectBase buildFieldError(Map<String, String> errors, ErrorCode statusCode) {

        JsonObjectError json = new JsonObjectError();
        json.setStatus(statusCode.getCode());

        for (String str : errors.keySet()) {
            json.addFieldError(str, contextReader.getMessage(errors.get(str)));
        }

        LOG.info(json.toString());

        return json;
    }
689753
public function getErrorType($code)
    {
        switch ($code) {
            case E_ERROR:
                return self::$stack['type'] = 'Error'; // 1
            case E_WARNING:
                return self::$stack['type'] = 'Warning'; // 2
            case E_PARSE:
                return self::$stack['type'] = 'Parse'; // 4
            case E_NOTICE:
                return self::$stack['type'] = 'Notice'; // 8
            case E_CORE_ERROR:
                return self::$stack['type'] = 'Core-Error'; // 16
            case E_CORE_WARNING:
                return self::$stack['type'] = 'Core Warning'; // 32
            case E_COMPILE_ERROR:
                return self::$stack['type'] = 'Compile Error'; // 64
            case E_COMPILE_WARNING:
                return self::$stack['type'] = 'Compile Warning'; // 128
            case E_USER_ERROR:
                return self::$stack['type'] = 'User Error'; // 256
            case E_USER_WARNING:
                return self::$stack['type'] = 'User Warning'; // 512
            case E_USER_NOTICE:
                return self::$stack['type'] = 'User Notice'; // 1024
            case E_STRICT:
                return self::$stack['type'] = 'Strict'; // 2048
            case E_RECOVERABLE_ERROR:
                return self::$stack['type'] = 'Recoverable Error'; // 4096
            case E_DEPRECATED:
                return self::$stack['type'] = 'Deprecated'; // 8192
            case E_USER_DEPRECATED:
                return self::$stack['type'] = 'User Deprecated'; // 16384
            default:
                return self::$stack['type'] = 'Error';
        }
    }
453065
protected String getErrorCodeFrom(final Map<String, Object> model) {
        return model.get(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_CODE).toString();
    }
135274
static CentralDogmaException convert(Throwable t) {
        t = Exceptions.peel(t);

        if (t instanceof CentralDogmaException) {
            return (CentralDogmaException) t;
        }

        ErrorCode code = ErrorCode.INTERNAL_SERVER_ERROR;
        if (t instanceof IllegalArgumentException) {
            code = ErrorCode.BAD_REQUEST;
        } else if (t instanceof EntryNotFoundException) {
            code = ErrorCode.ENTRY_NOT_FOUND;
        } else if (t instanceof RevisionNotFoundException) {
            code = ErrorCode.REVISION_NOT_FOUND;
        } else if (t instanceof QueryExecutionException) {
            code = ErrorCode.QUERY_FAILURE;
        } else if (t instanceof RedundantChangeException) {
            code = ErrorCode.REDUNDANT_CHANGE;
        } else if (t instanceof ChangeConflictException) {
            code = ErrorCode.CHANGE_CONFLICT;
        } else if (t instanceof ProjectNotFoundException) {
            code = ErrorCode.PROJECT_NOT_FOUND;
        } else if (t instanceof ProjectExistsException) {
            code = ErrorCode.PROJECT_EXISTS;
        } else if (t instanceof RepositoryNotFoundException) {
            code = ErrorCode.REPOSITORY_NOT_FOUND;
        } else if (t instanceof RepositoryExistsException) {
            code = ErrorCode.REPOSITORY_EXISTS;
        } else if (t instanceof ShuttingDownException) {
            code = ErrorCode.SHUTTING_DOWN;
        }

        final CentralDogmaException cde = new CentralDogmaException(code);
        cde.setMessage(t.toString());
        cde.initCause(t);
        return cde;
    }