@param \Exception $exception

@param string     $type

@return MbView
185616
public function exceptionFlash(\Exception $exception, $type = 'error')
    {
        if ($exception instanceof MbException) {
            $messages = $exception->getMessages();

            if (empty($messages)) {
                return $this->errorFlash($exception->getMessage(), $type);
            } else {
                $erros = [$exception->getMessage()];

                foreach ($messages as $item => $message) {
                    if (is_array($message)) {
                        foreach ($message as $erro) {
                            $erros[] = "<strong>{$item}</strong>: {$erro}";
                        }
                    } else {
                        $erros[] = $message;
                    }
                }

                return $this->errorFlash($erros, $type);
            }

        } else {
            return $this->errorFlash($exception->getMessage(), $type);
        }
    }
137918
public function getImagesOfType($type)
    {
        // Check to see if type is here.
        if (! in_array($type, $this->getImageTypes())) {
            throw new \Exception('Type not found in model '.self::class);
        }

        return $this->images()->where('image_type', '=', $type)->get();
    }
166053
public function action($m, $type, $args = [])
    {
        if (!is_array($args)) {
            throw new Exception([
                '$args must be an array',
                'args' => $args,
            ]);
        }

        $action = $this->initAction($m, isset($args[0]) ? $args[0] : null);

        $this->applyConditions($m, $action);
        $this->setLimitOrder($m, $action);

        switch ($type) {
            case 'select':

                return $action;

            case 'count':

                return $action->count();

            /* These are not implemented yet
            case 'field':

                $field = is_string($args[0]) ? $m->getField($args[0]) : $args[0];

                return $action->filterField($field->short_name);

            case 'fx':
            case 'fx0':

                return $action->aggregate($field->short_name, $fx);
            */

            default:
                throw new Exception([
                    'Unsupported action mode',
                    'type' => $type,
                ]);
        }
    }
98751
public function exception($e) {
        $type = "system";
        if (isset($_GET['type'])) {
            $type = $_GET['type'];
        }
        switch ($type) {
        case 'dapi':
        case 'api':
            $this->exception[] = $e;
            break;
        case 'page':
        default:
            require __DIR__ . '/exception.php';
            break;
        }
    }
1033132
public function blob( $type = 'PNG' ) {

        $type = strtoupper($type);
        if ( ImageType::GIF == $type ) {

            imagegif( $this->gd );

        } else if ( ImageType::JPEG == $type ) {

            imagejpeg( $this->gd );

        } else if ( ImageType::PNG == $type ) {

            imagepng( $this->gd );

        } else if ( ImageType::WBMP == $type ) {

            imagewbmp( $this->gd );

        } else {
            throw new \Exception( sprintf( 'File type "%s" not supported.', $type ) );
        }
    }
1279693
protected function addError(\Exception $exception)
    {
        $this->errorList[$exception->getCode()] = [
            'message'   => $exception->getMessage(),
            'line'      => $exception->getLine(),
            'file'      => $exception->getFile(),
            'trace'     => $exception->getTraceAsString(),
        ];
        $this->hasErrors = true;

        return $this;
    }
1331143
public function setType($type)
    {
        if ($type != PdfConverter::URL && $type != PdfConverter::HTML) {
            throw new \Exception('Wrong type of file descriptor');
        }

        $this->type = $type;

        return $this;
    }
1159930
public function build($type)
    {
        if (!isset($this->types[$type])) {
            throw new \Exception("Unknown request type.");
        }
        return new $this->types[$type]();
    }
1303270
public function display(Exception $exception, $code)
    {
        $content = $this->whoops()->handleException($exception);
        if( $this->request->wantsJson() ) {
            return Response::create( $content, $code )->header( 'Content-Type', 'application/json');
        } else {
            return Response::create( $content, $code);
        }
    }
1051047
protected function listFiles($type)
    {
        if (!isset($this->cache['files'][$type])) {
            $path = sprintf('%s/%s', $this->directory, $type);

            if (!$this->files->exists($path)) {
                throw new Exception(sprintf(
                    'No content directory found for type "%s" (in "%s").',
                    $type,
                    $this->directory
                ));
            }

            $finder = new Finder();

            $this->cache['files'][$type] = $finder->files()->in($path);
        }

        return clone $this->cache['files'][$type];
    }
349035
public function createErrorView($errorMessage, $exception, $displayExceptions = false, $displayNavMenu = false )
    {
      $viewModel = new ViewModel(array(
          'navMenu' => $displayNavMenu,
          'display_exceptions' => $displayExceptions,
          'errorMessage' => $errorMessage,
          'exception' => $exception,
      ));
      $viewModel->setTemplate('csn-user/error/error');
      return $viewModel;
    }
612050
public function convertExceptionToHtml($exception)
    {
        $flat = $this->getFlattenedException($exception);

        $handler = new SymfonyExceptionHandler();

        return $this->decorate($handler->getContent($flat), $handler->getStylesheet($flat), $flat);
    }
1041646
public static function addAlternativeTypeInformation(
        string $type,
        UnmappableInput $exception
    ): UnmappableInput {
        return new self(sprintf(
            '%s It could not be mapped to %s either.',
            $exception->getMessage(),
            $type
        ), 0, $exception);
    }
936616
public function transform(Exception $exception)
    {
        if ($exception instanceof ModelNotFoundException) {
            $exception = new NotFoundHttpException($exception->getMessage(), $exception, $exception->getCode());
        }

        return $exception;
    }
185893
public function getHtml($exception)
    {
        if (!$exception instanceof FlattenException) {
            $exception = FlattenException::create($exception);
        }

        return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
    }
273036
private static function _formatException($exception)
    {
        return str_replace(realpath(BASE_PATH), '', \Mmi\App\FrontController::getInstance()->getEnvironment()->requestUri . ' (' . $exception->getMessage() . ') @' .
            $exception->getFile() . '(' . $exception->getLine() . ') ' .
            self::_formatTrace($exception));
    }
355939
public function fetchData($filename, $type) {
        $absPath    = $this->_getAbsPath($filename, $type);
        $sftpStream = $this->getSftpStream($absPath, 'rb');

        $content    = $this->_fetchAndCloseStream($sftpStream);

        if ($content !== false) {
            return $content;
        } else throw new Exception("Could not read {$absPath} on " . $this->getEnvironment());
    }