response when publishing failed

@param mixed $type
@param String $error
@return \Illuminate\Http\RedirectResponse
180889
public function publishFailed($type, $error = null)
    {
        app('antares.messages')->add('error', is_null($error) ? trans('Translations has not been published.') : $error);
        return redirect(handles('antares::translations/index/' . $type));
    }
1284279
public function updateAuthFailed(array $errors)
    {
        $message = trans('antares/api::response.configuration.update.failed');
        $url     = handles('antares::api/configuration');

        return $this->redirectWithMessage($url, $message, 'error');
    }
851959
public function handle(Request $request, $type = self::MASTER_REQUEST)
    {
        try {
            $response = $this->handleRequest($request, $type);
        } catch (\Exception $e) {
            $response = $this->handleException($e, $request, $type);
        }

        return $response;
    }
104209
protected function getNotFoundPage($error)
    {
        return new Response($this->twig->render('@crud/notFound.twig', [
            'crud' => $this->service,
            'error' => $error,
            'crudEntity' => '',
            'layout' => $this->service->getTemplate('layout', '', '')
        ]), 404);
    }
368824
final protected function header(string $content, string $type = null)
    {
        Response::header($content, $type);
    }
857113
public function getFailedRedirect($route, $message = 'flash_bag.error.default', $routeParameters = [], $routeFragment = null, $translationDomain = null)
    {
        $this->addSessionFlashBagMessage($message, Bootstrap4::STATE_DANGER, $translationDomain);

        return $this->getRedirectToRoute($route, $routeParameters);
    }
56061
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
    {
        $closure = $this->closure;

        return $closure($request);
    }
801559
protected function seeError(string $error, int $status = null)
    {
        if (! is_null($status)) {
            $this->seeStatusCode($status);
        }

        if ($this->app->config->get('responder.status_code')) {
            $this->seeJson([
                'status' => $status
            ]);
        }

        return $this->seeJson([
            'success' => false
        ])->seeJsonSubset([
            'error' => [
                'code' => $error
            ]
        ]);
    }
961548
public function redirect($uri, $type=HttpResponse::SC_MOVED_TEMPORARILY) {
        $request    = Request::me();
        $currentUrl = $request->getUrl();

        // HTTP/1.1 requires an absolute 'Location' value
        $url = self::relativeToAbsoluteUrl($uri, $currentUrl);

        // append session id if a session is active and URL rewriting is not disabled (strongly discouraged)
        if (defined('SID') && strlen(SID)) {                        // empty string if the session id was submitted in a cookie
            if (!ini_get_bool('session.use_only_cookies')) {        // TODO: check if session_destroy() resets SID
                $cookie       = session_get_cookie_params();
                $cookieDomain = strtolower(empty($cookie['domain']) ? $request->getHostname() : $cookie['domain']);
                $cookiePath   =            empty($cookie['path'  ]) ? '/'                     : $cookie['path'  ];
                $cookieSecure =                  $cookie['secure'];

                $target       = parse_url($url);
                $targetDomain = strtolower($target['host'  ]);
                $targetPath   =      empty($target['path'  ]) ? '/' : $target['path'];
                $targetSecure = strtolower($target['scheme']) == 'https';

                $subdomains = false;
                if ($cookieDomain[0] == '.') {                      // TODO: check if the leading dot is still required
                    $subdomains = true;                             //       (@see http://bayou.io/draft/cookie.domain.html)
                    $cookieDomain = substr($cookieDomain, 1);
                }

                if ($domainMatch = (preg_match('/\b'.$cookieDomain.'$/', $targetDomain) && ($cookieDomain==$targetDomain || $subdomains))) {
                    if ($pathMatch = strStartsWith($targetPath, $cookiePath)) {
                        if ($secureMatch = (!$cookieSecure || $targetSecure)) {
                            if (isset($target['fragment']))  $url  = strLeft($url, strlen($hash = '#'.$target['fragment']));
                            else if (strEndsWith($url, '#')) $url  = strLeft($url, strlen($hash = '#'));
                            else                             $hash = '';

                            $separator = !strContains($url, '?') ? '?' : '&';
                            $url .= $separator.SID.$hash;
                        }
                    }
                }
            }
        }

        // set the header
        header('Location: '.$url, true, $type);

        // terminate the script
        exit(0);
    }
1371536
protected function _handleRedirect($type, $options) {
		if (isset($options[$type . 'RedirectUrl']) && $options[$type . 'RedirectUrl'] !== false) {
			$controller = $this->getController();
			$result = $controller->redirect($options[$type . 'RedirectUrl']);
			$this->_redirectResponse = $result;

			return $result;
		}

		$this->_redirectResponse = null;

		return false;
	}
445665
public function redirect($path, $type = 302, $end = true)
    {
        // $type should be one of the following:
        // 301 = Moved permanently
        // 302 = Temporary redirect
        // 303 = Perform GET at new location (instead of POST)

        if (headers_sent()) {
            if (self::$exceptOnHeaders) {
                throw new \Exception('Headers already sent. Redirect cannot be initiated.');
            } else {
                return;
            }
        }

        if (self::$outputBuffering) {
            $this->cleanBuffer();
        }

        $this->code($type);
        header('Location: '. $path);

        if ($end) {
            exit;
        }
    }
926020
public function updateRuleFailed(array $errors)
    {
        $url     = handles('antares::ban_management/rules/datatable');
        $message = trans('antares/ban_management::response.rules.update.db-failed', $errors);

        return $this->redirectWithMessage($url, $message, 'error');
    }
455230
function redirect($url, $type = 303) {
		if ($type == 303) {
			// 303 See Other
			$this->responseCode(303);
		}
		else if ($type == 301) {
			// 301 Moved Permanently
			$this->responseCode(301);
		}
		else if ($type == 307) {
			// 307 Temporary Redirect
			$this->responseCode(307);
		}

		// redirect to...
		$this->header("Location: $url");
	}
30563
protected function trigger_error( $code, $message, $type = E_USER_NOTICE ){
		$trace = debug_backtrace();
		$Err = PLUG::raise_error( $code, $message, $type, $trace );
		$this->on_trigger_error( $Err );
	}
118266
protected function modelHasBeenSaved($saved, $type, $request)
    {
        if (!$saved) {
            return response()->json(['message' => 'Failed to '.$type.' resource', 'code' => 422], 422);
        }
        $status = $request->ajax() ? 202 : 200;
        if ($request->ajax()) {
            return response()->json(['message' => 'Successfully '.$type.' resource', 'code' => $status], $status);
        }
        if ($request->has('_redirect')) {
            // Remove the base part of the url, and just grab the tail end of the desired redirect, that way the
            // User can't be redirected away from your website.
            return $this->returnRedirect('Successfully '.$type.' resource', $request);
        }

        return redirect()->back()->with(['message' => 'Successfully '.$type.' resource']);
    }
1170675
protected function checkError(Response $response, $method, $url = null)
    {
        if ($response->getStatusCode() === Response::HTTP_OK) {
            return;
        }
        if (null === $url) {
            $url = $this->url;
        }
        throw new PublicationException(
            "Failed to send ({$method}) data to {$url}",
            $response->getStatusCode(),
            $response
        );
    }
533631
public function publish($type, $data)
    {
        $context = $this->_context;

        $packet = $context->header;

        $packet['type'] = $type;
        $packet['data'] = $data;

        /** @noinspection PhpUndefinedMethodInspection */
        /** @var \Redis $redis */
        $redis = $this->redis->getConnection();
        $r = $redis->publish($context->channel, json_encode($packet, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
        if ($r <= 0) {
            $this->_enabled = false;
            $this->_last_checked = microtime(true);
        }

        return $r;
    }