Returns an error descriptor object with the error code if validation fails.

@param       {[type]} authorize_request
@return      {[type]}
494520
function __validate_authorization_request(authorize_request) {
    return new Promise((resolve, reject) => {
        let error_object = {
            error: "invlalid_request",
            error_description: ""
        };

        if (authorize_request.state) {
            error_object.state = authorize_request.state;
        }

        if (authorize_request.nonce) {
            error_object.nonce = authorize_request.nonce;
        }

        let openid_scope_found = authorize_request
            .scope
            .split(" ")
            .find((element, idx, arr) => {
                if (element.trim() === "openid") {
                    return true;
                }
            });

        if (!openid_scope_found) {
            error_object.error = "invalid_scope";
            error_object.error_description = "scope must include openid";
            return reject(error_object);
        }

        if ((!authorize_request.response_type) || (authorize_request.response_type.trim() !== "code")) {
            error_object.error = "unsupported_response_type";
            error_object.error_description = "Only Authorization Code Flow is supported.";
            return reject(error_object);
        }

        return resolve(authorize_request);
    });
}
78112
def http_error_401(self, url, fp, errcode, errmsg, headers, data=None,
            retry=False):
        """"""
        if 'www-authenticate' not in headers:
            URLopener.http_error_default(self, url, fp,
                                         errcode, errmsg, headers)
        stuff = headers['www-authenticate']
        match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
        if not match:
            URLopener.http_error_default(self, url, fp,
                                         errcode, errmsg, headers)
        scheme, realm = match.groups()
        if scheme.lower() != 'basic':
            URLopener.http_error_default(self, url, fp,
                                         errcode, errmsg, headers)
        if not retry:
            URLopener.http_error_default(self, url, fp, errcode, errmsg,
                    headers)
        name = 'retry_' + self.type + '_basic_auth'
        if data is None:
            return getattr(self,name)(url, realm)
        else:
            return getattr(self,name)(url, realm, data)
1280765
function (form) {
            var options = {
              login: form.data.email
            };

            if (req.organization) {
              options.accountStore = {
                href: req.organization.href
              };
            }

            application.resendVerificationEmail(options, function (err, account) {
              // Code 2016 means that an account does not exist for the given email
              // address.  We don't want to leak information about the account
              // list, so allow this continue without error.
              if (err && err.code !== 2016) {
                logger.info('A user tried to resend their account verification email, but failed: ' + err.message);
                return helpers.render(req, res, view, { error: err.message, form: form });
              }

              if (account) {
                emailVerificationHandler(new Account(account));
              }

              res.redirect(config.web.login.uri + '?status=unverified');
            });
          }
1203134
def _create_error(self, status_code):
        

        return jsend.error(message=ComodoCA.status_code[status_code], code=status_code)
285244
function errorSerializer (err) {
  if (!err || !err.stack) return err
  const obj = {
    message: err.message,
    name: err.name,
    code: err.code,
    stack: getErrorStack(err)
  }
  return obj
}
860797
function errorHandler(error, req, res, next) {
    req.body.email = '';
    req.body.subscribed_url = santizeUrl(req.body.subscribed_url);
    req.body.subscribed_referrer = santizeUrl(req.body.subscribed_referrer);

    if (error.statusCode !== 404) {
        res.locals.error = error;
        return _renderer(req, res);
    }

    next(error);
}
1322422
def openid_authorization_validator(self, request):
        
        request_info = super(HybridGrant, self).openid_authorization_validator(request)
        if not request_info:  # returns immediately if OAuth2.0
            return request_info

        # REQUIRED if the Response Type of the request is `code
        # id_token` or `code id_token token` and OPTIONAL when the
        # Response Type of the request is `code token`. It is a string
        # value used to associate a Client session with an ID Token,
        # and to mitigate replay attacks. The value is passed through
        # unmodified from the Authentication Request to the ID
        # Token. Sufficient entropy MUST be present in the `nonce`
        # values used to prevent attackers from guessing values. For
        # implementation notes, see Section 15.5.2.
        if request.response_type in ["code id_token", "code id_token token"]:
            if not request.nonce:
                raise InvalidRequestError(
                    request=request,
                    description='Request is missing mandatory nonce parameter.'
                )
        return request_info
283908
function checkDescriptor(descriptor, err){
	if(typeof descriptor != 'object') return false;
	
	for(var key in CONST.descriptorType){
		if(!checkType(descriptor[key], CONST.descriptorType[key])){
			err.key = key;
			err.expect = CONST.descriptorType[key];
			err.type = typeof descriptor[key];
			return false;
		}
	}

	for(var key in CONST.descriptorOptType){
		if(typeof descriptor[key] != 'undefined' && checkType(descriptor[key], CONST.descriptorOptType[key].type)) continue;
		if(typeof descriptor[key] == 'undefined'){
			if(typeof CONST.descriptorOptType[key].value != 'undefined') descriptor[key] = CONST.descriptorOptType[key].value;
			continue;
		}

		err.key = key;
		err.expect = CONST.descriptorOptType[key].type;
		err.type = typeof descriptor[key];
		return false;
	}

	return true;
}
712274
function getTokenFromHeader(request) {
  if (!request.headers || !request.headers.has('authorization')) {
    throw new UnauthorizedError('No authorization header present');
  }

  const parts = request.headers.get('authorization').split(" ");

  if (parts.length === 2) {
    const scheme = parts[0];
    const credentials = parts[1];

    if (/^Bearer$/i.test(scheme)) {
      return credentials;
    } else {
      throw new UnauthorizedError('Bad Authorization header format. Format is "Authorization: Bearer token"');
    }
  } else {
    throw new UnauthorizedError('Bad Authorization header format. Format is "Authorization: Bearer token"');
  }
}
725609
def _get_err(self, e, id=None, jsonrpc=DEFAULT_JSONRPC):
        
        # Do not respond to notifications when the request is valid.
        if not id \
                and not isinstance(e, ParseError) \
                and not isinstance(e, InvalidRequestError):
            return None

        respond = {'id': id}

        if isinstance(jsonrpc, int):
            # v1.0 requires result to exist always.
            # No error codes are defined in v1.0 so only use the message.
            if jsonrpc == 10:
                respond['result'] = None
                respond['error'] = e.dumps()['message']
            else:
                self._fill_ver(jsonrpc, respond)
                respond['error'] = e.dumps()
        else:
            respond['jsonrpc'] = jsonrpc
            respond['error'] = e.dumps()

        return respond
429425
function handleUnauthorizedAPIResponse(error) {
    const response = error && error.response;
    const errorStatus = response && response.status;
    const requestUrl = response && response.config && response.config.url;
    const requestIsTokenRefresh = requestUrl === authenticatedAPIClient.refreshAccessTokenEndpoint;

    switch (errorStatus) { // eslint-disable-line default-case
      case 401:
        if (requestIsTokenRefresh) {
          logInfo(`Unauthorized token refresh response from ${requestUrl}. This is expected if the user is not yet logged in.`);
        } else {
          logInfo(`Unauthorized API response from ${requestUrl}`);
        }
        break;
      case 403:
        logInfo(`Forbidden API response from ${requestUrl}`);
        break;
    }

    return Promise.reject(error);
  }
1321264
function oktaErrorTransformer(err) {
  if (err && err.errorCauses) {
    err.errorCauses.forEach(function (cause) {
      if (cause.errorSummary === 'login: An object with this field already exists in the current organization') {
        err.userMessage = 'An account with that email address already exists.';
      } else if (!err.userMessage) {
        // This clause allows the first error cause to be returned to the user
        err.userMessage = cause.errorSummary;
      }
    });
  }

  // For OAuth errors
  if (err && err.error_description) {
    err.message = err.error_description;
  }

  if (err && err.error === 'invalid_grant') {
    err.status = 400;
    err.code = 7104;
    err.message = 'Invalid username or password.';
  }

  return err;
}
533560
function(errOrMessage, result) {
        var err = (errOrMessage instanceof Error) ? errOrMessage : new Error(errOrMessage);
        result = result || {};
        result.error = err;
        result.status = 'error';
        err.result = result;
        return err;
    }
942453
function errorBadCredentials(res) {
  var err = new Error('Invalid credentials');
  err.res = res;
  err.remote = 'github-content-api';
  throw err;
}
611874
function onClientError(err, res) {
    if ((err || {}).name === 'SizeLimitExceededError') {
      onSearchEnd(res);
      return;
    }

    client.unbind();
    log.error(err, '[%s] An error occurred performing the requested LDAP search on %s (%j)',
              (err || {}).errno || 'UNKNOWN', baseDN, opts);
    if (callback) callback(err);
  }
576862
def _wrap_client_error(e):
    
    error_code = e.response['Error']['Code']
    message = e.response['Error']['Message']

    if error_code == 'BadRequestException':
        if "Failed to copy S3 object. Access denied:" in message:
            match = re.search('bucket=(.+?), key=(.+?)$', message)
            if match:
                return S3PermissionsRequired(bucket=match.group(1), key=match.group(2))
        if "Invalid S3 URI" in message:
            return InvalidS3UriError(message=message)

    return ServerlessRepoClientError(message=message)
1169982
function defaultErrorHandler(err, req, res) {
  if (err.name === 'UnauthorizedError') { // authentication is expected to be a common use-case
    res.status(401).end();
  } else {
    if (!err.status || err.status >= 500) {
      console.error(err.stack || err.toString());
    }
    res.status(err.status || 500).json({message: err.message})
  }
}