protected function handleStreamException(StreamException $e, $typeError, $read = true)
    {
        $strType = 'unknown datatype';

        switch ($typeError) {
            case BinaryStreamAccessException::BOOLEAN:
                $strType = 'boolean';
            break;

            case BinaryStreamAccessException::BINARY:
                $strType = 'binary data';
            break;

            case BinaryStreamAccessException::FLOAT:
                $strType = 'double precision float';
            break;

            case BinaryStreamAccessException::INT:
                $strType = 'integer';
            break;

            case BinaryStreamAccessException::SHORT:
                $strType = 'short integer';
            break;

            case BinaryStreamAccessException::STRING:
                $strType = 'string';
            break;

            case BinaryStreamAccessException::TINYINT:
                $strType = 'tiny integer';
            break;

            case BinaryStreamAccessException::DATETIME:
                $strType = 'datetime';
            break;
        }

        $strAction = ($read === true) ? 'reading' : 'writing';

        switch ($e->getCode()) {
            case StreamException::NOT_OPEN:
                $strAction = ucfirst($strAction);
                $msg = "${strAction} a ${strType} from a closed binary stream is not permitted.";
                throw new BinaryStreamAccessException($msg, $this, BinaryStreamAccessException::NOT_OPEN, $e);
                break;

            case StreamException::READ:
                $msg = "An error occured while ${strAction} a ${strType}.";
                throw new BinaryStreamAccessException($msg, $this, $typeError, $e);
                break;

            default:
                $msg = "An unknown error occured while ${strAction} a ${strType}.";
                throw new BinaryStreamAccessException($msg, $this, BinaryStreamAccessException::UNKNOWN, $e);
                break;
        }
    }
protected function handleStreamException(StreamException $e, $typeError, $read = true)
    {
        $strType = 'unknown datatype';

        switch ($typeError) {
            case BinaryStreamAccessException::BOOLEAN:
                $strType = 'boolean';
            break;

            case BinaryStreamAccessException::BINARY:
                $strType = 'binary data';
            break;

            case BinaryStreamAccessException::FLOAT:
                $strType = 'double precision float';
            break;

            case BinaryStreamAccessException::INT:
                $strType = 'integer';
            break;

            case BinaryStreamAccessException::SHORT:
                $strType = 'short integer';
            break;

            case BinaryStreamAccessException::STRING:
                $strType = 'string';
            break;

            case BinaryStreamAccessException::TINYINT:
                $strType = 'tiny integer';
            break;

            case BinaryStreamAccessException::DATETIME:
                $strType = 'datetime';
            break;
        }

        $strAction = ($read === true) ? 'reading' : 'writing';

        switch ($e->getCode()) {
            case StreamException::NOT_OPEN:
                $strAction = ucfirst($strAction);
                $msg = "${strAction} a ${strType} from a closed binary stream is not permitted.";
                throw new BinaryStreamAccessException($msg, $this, BinaryStreamAccessException::NOT_OPEN, $e);
                break;

            case StreamException::READ:
                $msg = "An error occured while ${strAction} a ${strType}.";
                throw new BinaryStreamAccessException($msg, $this, $typeError, $e);
                break;

            default:
                $msg = "An unknown error occured while ${strAction} a ${strType}.";
                throw new BinaryStreamAccessException($msg, $this, BinaryStreamAccessException::UNKNOWN, $e);
                break;
        }
    }
protected function handleStreamException ( StreamException $ e , $ typeError , $ read = true ) { $ strType = 'unknown datatype' ; switch ( $ typeError ) { case BinaryStreamAccessException :: BOOLEAN : $ strType = 'boolean' ; break ; case BinaryStreamAccessException :: BINARY : $ strType = 'binary data' ; break ; case BinaryStreamAccessException :: FLOAT : $ strType = 'double precision float' ; break ; case BinaryStreamAccessException :: INT : $ strType = 'integer' ; break ; case BinaryStreamAccessException :: SHORT : $ strType = 'short integer' ; break ; case BinaryStreamAccessException :: STRING : $ strType = 'string' ; break ; case BinaryStreamAccessException :: TINYINT : $ strType = 'tiny integer' ; break ; case BinaryStreamAccessException :: DATETIME : $ strType = 'datetime' ; break ; } $ strAction = ( $ read === true ) ? 'reading' : 'writing' ; switch ( $ e -> getCode ( ) ) { case StreamException :: NOT_OPEN : $ strAction = ucfirst ( $ strAction ) ; $ msg = "${strAction} a ${strType} from a closed binary stream is not permitted." ; throw new BinaryStreamAccessException ( $ msg , $ this , BinaryStreamAccessException :: NOT_OPEN , $ e ) ; break ; case StreamException :: READ : $ msg = "An error occured while ${strAction} a ${strType}." ; throw new BinaryStreamAccessException ( $ msg , $ this , $ typeError , $ e ) ; break ; default : $ msg = "An unknown error occured while ${strAction} a ${strType}." ; throw new BinaryStreamAccessException ( $ msg , $ this , BinaryStreamAccessException :: UNKNOWN , $ e ) ; break ; } }
Handle a StreamException in order to throw the relevant BinaryStreamAccessException.

@param \qtism\common\storage\StreamException $e The StreamException object to deal with.
@param integer $typeError The BinaryStreamAccess exception code to be thrown in case of error.
@param boolean $read Wheter or not the error occured in a reading/writing context.
@throws \qtism\common\storage\BinaryStreamAccessException The resulting BinaryStreamAccessException.
Handle a StreamException in order to throw the relevant BinaryStreamAccessException .