The OutOfRangeException class

(PHP 5 >= 5.1.0, PHP 7)

Einf├╝hrung

Exception thrown when an illegal index was requested. This represents errors that should be detected at compile time.

Klassenbeschreibung

OutOfRangeException extends LogicException {
/* Geerbte Eigenschaften */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Geerbte Methoden */
public Exception::__construct ([ string $message = "" [, int $code = 0 [, Throwable $previous = NULL ]]] )
final public Exception::getMessage ( ) : string
final public Exception::getPrevious ( ) : Throwable
final public Exception::getCode ( ) : mixed
final public Exception::getFile ( ) : string
final public Exception::getLine ( ) : int
final public Exception::getTrace ( ) : array
final public Exception::getTraceAsString ( ) : string
public Exception::__toString ( ) : string
final private Exception::__clone ( ) : void
}
add a note add a note

User Contributed Notes 2 notes

up
2
Jakub
3 years ago
I see this in this way:
By definiton, OutOfRangeException should be use to when potential problem is logical - occurs because of wrong code or definition. OutOfBoundsException is for runtime.

Example (see also note in "OutOfBoundsException class" article):
<?php
function prepareData(PDOStatement $s) {
   
$x = $s->fetch();
    if (!isset(
$x['secretColumn']))
        throw new
OutOfRangeException ("Secret column doesn't exist! Verify table definition and query.");
}
up
0
evguenia dot chagnon at gmail dot com
3 years ago
Exemple :

$calendar = new Calendar();
$calendar->getMonth(15);
To Top