mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-05 17:21:16 +02:00
38 lines
861 B
PHP
38 lines
861 B
PHP
<?php
|
|
|
|
namespace SilverStripe\Logging\Tests\DetailedErrorFormatterTest;
|
|
|
|
use Exception;
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
/**
|
|
* WARNING: This file is sensitive to whitespace changes
|
|
*/
|
|
class ErrorGenerator implements TestOnly
|
|
{
|
|
/**
|
|
* Generate an exception with a trace depeth of at least 4
|
|
*
|
|
* @param int $depth
|
|
* @return Exception
|
|
* @throws Exception
|
|
*/
|
|
public function mockException($depth = 0)
|
|
{
|
|
switch ($depth) {
|
|
case 0:
|
|
try {
|
|
$this->mockException(1);
|
|
} catch (\Exception $ex) {
|
|
return $ex;
|
|
}
|
|
return null;
|
|
break;
|
|
case 4:
|
|
throw new Exception('Error');
|
|
default:
|
|
return $this->mockException($depth + 1);
|
|
}
|
|
}
|
|
}
|