<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/appengine/v1/app_yaml.proto

namespace Google\Cloud\AppEngine\V1\ErrorHandler;

use UnexpectedValueException;

/**
 * Error codes.
 *
 * Protobuf type <code>google.appengine.v1.ErrorHandler.ErrorCode</code>
 */
class ErrorCode
{
    /**
     * Not specified. ERROR_CODE_DEFAULT is assumed.
     *
     * Generated from protobuf enum <code>ERROR_CODE_UNSPECIFIED = 0;</code>
     */
    const ERROR_CODE_UNSPECIFIED = 0;
    /**
     * All other error types.
     *
     * Generated from protobuf enum <code>ERROR_CODE_DEFAULT = 0;</code>
     */
    const ERROR_CODE_DEFAULT = 0;
    /**
     * Application has exceeded a resource quota.
     *
     * Generated from protobuf enum <code>ERROR_CODE_OVER_QUOTA = 1;</code>
     */
    const ERROR_CODE_OVER_QUOTA = 1;
    /**
     * Client blocked by the application's Denial of Service protection
     * configuration.
     *
     * Generated from protobuf enum <code>ERROR_CODE_DOS_API_DENIAL = 2;</code>
     */
    const ERROR_CODE_DOS_API_DENIAL = 2;
    /**
     * Deadline reached before the application responds.
     *
     * Generated from protobuf enum <code>ERROR_CODE_TIMEOUT = 3;</code>
     */
    const ERROR_CODE_TIMEOUT = 3;

    private static $valueToName = [
        self::ERROR_CODE_UNSPECIFIED => 'ERROR_CODE_UNSPECIFIED',
        self::ERROR_CODE_DEFAULT => 'ERROR_CODE_DEFAULT',
        self::ERROR_CODE_OVER_QUOTA => 'ERROR_CODE_OVER_QUOTA',
        self::ERROR_CODE_DOS_API_DENIAL => 'ERROR_CODE_DOS_API_DENIAL',
        self::ERROR_CODE_TIMEOUT => 'ERROR_CODE_TIMEOUT',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}


