Shortcut for an error

@param string $msg
@param string $url
@return SS_HTTPResponse
541753
protected function err($msg, $url = null)
    {
        $this->saveDataInSession();
        return $this->msg($msg, self::MSG_BAD, $url);
    }
248700
public function logError($error, $msg = '')
    {
        if (is_object($error)) {
            // we got exception object obviously
            $error = $error->getMessage();
        }
        $this->app->getLogger()->logLine($msg.' '.$error."\n", null, 'error');
    }
137803
protected function SetError($msg) {
    $this->error_count++;
    if (($this->Mailer == 'smtp') and ($this->smtp !== null)) {
      $lasterror = $this->smtp->getError();
      if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
        $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
      }
    }
    $this->ErrorInfo = $msg;
  }
294926
public static function processMessage ($msg)
  {
    $msg = preg_replace_callback ('#<path>([^<]*)</path>#', function ($m) {
      return ErrorConsole::errorLink ($m[1], 1, 1, self::shortFileName ($m[1]));
    }, $msg);
    return $msg;
  }
1314808
public function dispatch($msg)
    {
        if (is_string($msg)) {
            $msg = json_decode($msg);
            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new Error(json_last_error_msg(), ErrorCode::PARSE_ERROR);
            }
        }
        // Find out the object and function that should be called
        $obj = $this->target;
        $parts = explode($this->delimiter, $msg->method);
        // The function to call is always the last part of the method
        $fn = array_pop($parts);
        // For namespaced methods like textDocument/didOpen, call the didOpen method on the $textDocument property
        // For simple methods like initialize, shutdown, exit, this loop will simply not be entered and $obj will be
        // the target
        foreach ($parts as $part) {
            if (!isset($obj->$part)) {
                throw new Error("Method {$msg->method} is not implemented", ErrorCode::METHOD_NOT_FOUND);
            }
            $obj = $obj->$part;
        }
        if (!isset($this->methods[$msg->method])) {
            try {
                $method = new ReflectionMethod($obj, $fn);
                $this->methods[$msg->method] = $method;
            } catch (ReflectionException $e) {
                throw new Error($e->getMessage(), ErrorCode::METHOD_NOT_FOUND, null, $e);
            }
        }
        $method = $this->methods[$msg->method];
        $parameters = $method->getParameters();
        if ($method->getDocComment()) {
            $docBlock = $this->docBlockFactory->create(
                $method->getDocComment(),
                $this->contextFactory->createFromReflector($method->getDeclaringClass())
            );
            $paramTags = $docBlock->getTagsByName('param');
        }
        $args = [];
        if (isset($msg->params)) {
            // Find out the position
            if (is_array($msg->params)) {
                $args = $msg->params;
            } else if (is_object($msg->params)) {
                foreach ($parameters as $pos => $parameter) {
                    $value = null;
                    foreach(get_object_vars($msg->params) as $key => $val) {
                        if ($parameter->name === $key) {
                            $value = $val;
                            break;
                        }
                    }
                    $args[$pos] = $value;
                }
            } else {
                throw new Error('Params must be structured or omitted', ErrorCode::INVALID_REQUEST);
            }
            foreach ($args as $position => $value) {
                try {
                    // If the type is structured (array or object), map it with JsonMapper
                    if (is_object($value)) {
                        // Does the parameter have a type hint?
                        $param = $parameters[$position];
                        if ($param->hasType()) {
                            $class = (string)$param->getType();
                            $value = $this->mapper->map($value, new $class());
                        }
                    } else if (is_array($value) && isset($docBlock)) {
                        // Get the array type from the DocBlock
                        $type = $paramTags[$position]->getType();
                        // For union types, use the first one that is a class array (often it is SomeClass[]|null)
                        if ($type instanceof Types\Compound) {
                            for ($i = 0; $t = $type->get($i); $i++) {
                                if (
                                    $t instanceof Types\Array_
                                    && $t->getValueType() instanceof Types\Object_
                                    && (string)$t->getValueType() !== 'object'
                                ) {
                                    $class = (string)$t->getValueType()->getFqsen();
                                    $value = $this->mapper->mapArray($value, [], $class);
                                    break;
                                }
                            }
                        } else if ($type instanceof Types\Array_) {
                            $class = (string)$type->getValueType()->getFqsen();
                            $value = $this->mapper->mapArray($value, [], $class);
                        } else {
                            throw new Error('Type is not matching @param tag', ErrorCode::INVALID_PARAMS);
                        }
                    }
                } catch (JsonMapper_Exception $e) {
                    throw new Error($e->getMessage(), ErrorCode::INVALID_PARAMS, null, $e);
                }
                $args[$position] = $value;
            }
        }
        ksort($args);
        $result = $obj->$fn(...$args);
        return $result;
    }
831848
protected function msg($msg, $type, $url = null)
    {
        $this->sessionMessage($msg, $type);
        if ($url) {
            return $this->Controller()->redirect($url);
        }
        return $this->Controller()->redirectBack();
    }
433562
public function format_error_message($errormsg) {
        $errors = unserialize($errormsg);
        $output = 'mnet_xmlrpc_client request returned errors:'."\n";
        foreach ($errors as $error) {
            $output .= "$error\n";
        }
        return $output;
    }
1219975
private static function applicationErrorToException($error,
                                                      $destination_url) {
    switch ($error->getApplicationError()) {
      case ErrorCode::REDIRECT_URL_TOO_LONG:
        return new UsersException('URL too long: ' . $destination_url);
      case ErrorCode::NOT_ALLOWED:
        return new UsersException('Action not allowed.');
      default:
        return new UsersException(
            'Error code: ' . $error->getApplicationError());
    }
  }
1029605
public function unauthorized($msg = '', $errorCode = null, $headers = [])
    {
        return $this->getErrorResponse($msg, $errorCode, self::HTTP_UNAUTHORIZED, $headers);
    }
1059417
protected function success($msg = '', $url = null, $data = '', $wait = 3)
    {
        if (is_null($url)) {
            $url = Request::instance()->isAjax() ? '' : 'javascript:history.back(-1);';
        }

        $result = [
            'code' => 1,
            'msg'  => $msg,
            'data' => $data,
            'url'  => $url,
            'wait' => $wait,
        ];

        if (Request::instance()->isPost()) {
            header('Content-type: application/json; charset=utf-8');
            die(json_encode($result));
        } else {
            die(include HOPE_PATH . 'temp/jump.php');
        }
    }
815056
function error(status, msg) {
  var err = new Error(msg);
  err.status = status;
  return err;
}
621276
public static function notNullText(
        $msg = '',
        $default = null,
        $noValidMessage = null,
        $attemptTimes = 3,
        $failCloseMessage = false
    ) {
        $prompter = new NotNullPrompter();

        static::prepareCallbackPrompter($prompter, $noValidMessage, $attemptTimes, $failCloseMessage);

        return $prompter->ask($msg, $default);
    }
1268396
protected function error($msg, array $bind = [])
    {
        foreach ($bind as $key => $value) {
            if (is_null($value)) {
                $value = 'NULL';
            } elseif (is_bool($value)) {
                $value = $value ? 'true' : 'false';
            }
            $msg .= "$key => $value\n";
        }
        return $msg;
    }
942985
protected function showError($msg = null)
    {
        if ($msg === null) {
            $msg = 'Sitemap is not available, please check your configuration';
        }

        header('HTTP/1.0 503 Service Unavailable');
        $GLOBALS['TSFE']->pageErrorHandler(true, null, $msg);
        exit;
    }
295329
def error(self, msg):
        
        body = msg['body'].replace(NULL, '')

        brief_msg = ""
        if 'message' in msg['headers']:
            brief_msg = msg['headers']['message']

        self.log.error("Received server error - message%s\n\n%s" % (brief_msg, body))

        returned = NO_RESPONSE_NEEDED
        if self.testing:
            returned = 'error'

        return returned
1371539
public function url($msg)
    {
        if(strlen(trim($this->_value)) > 0 && filter_var($this->_value, FILTER_VALIDATE_URL) === FALSE) {
            $this->_errors[] = $msg;
        }
        return $this;
    }
280519
private function connection_open_fail($msg='') {
		$logline = sprintf('Redis: %s connection failed',
			$this->redistype);
		if ($msg)
			$logline .= ': ' . $msg;
		$logline .= ' <- ' . json_encode($this->verified_params);
		self::$logger->error($logline);
		throw new RedisError(RedisError::CONNECTION_ERROR,
			$logline);
	}