Skip to content

Commit

Permalink
custom exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
janmarek committed Feb 14, 2012
1 parent 6c4ccab commit a196e2f
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Compiler.php
Expand Up @@ -67,7 +67,7 @@ public function setOutputDir($tempPath)
}

if (!is_writable($tempPath)) {
throw new \InvalidArgumentException("Directory '$tempPath' is not writeable.");
throw new InvalidArgumentException("Directory '$tempPath' is not writeable.");
}

$this->outputDir = $tempPath;
Expand Down Expand Up @@ -225,12 +225,12 @@ public function setOutputNamingConvention(IOutputNamingConvention $namingConvent

/**
* @param callback $filter
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function addFilter($filter)
{
if (!is_callable($filter)) {
throw new \InvalidArgumentException('Filter is not callable.');
throw new InvalidArgumentException('Filter is not callable.');
}

$this->filters[] = $filter;
Expand All @@ -246,12 +246,12 @@ public function getFilters()

/**
* @param callback $filter
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function addFileFilter($filter)
{
if (!is_callable($filter)) {
throw new \InvalidArgumentException('Filter is not callable.');
throw new InvalidArgumentException('Filter is not callable.');
}

$this->fileFilters[] = $filter;
Expand Down
2 changes: 1 addition & 1 deletion FileNotFoundException.php
Expand Up @@ -7,7 +7,7 @@
*
* @author Jan Marek
*/
class FileNotFoundException extends \Exception
class FileNotFoundException extends WebLoaderException
{

}
2 changes: 1 addition & 1 deletion Filter/CssUrlsFilter.php
Expand Up @@ -22,7 +22,7 @@ public function __construct($docRoot, $basePath = '/')
$this->docRoot = realpath($docRoot);

if (!is_dir($this->docRoot)) {
throw new \InvalidArgumentException('Given document root is not directory.');
throw new \WebLoader\InvalidArgumentException('Given document root is not directory.');
}

$this->basePath = $basePath;
Expand Down
4 changes: 2 additions & 2 deletions Filter/VariablesFilter.php
Expand Up @@ -80,14 +80,14 @@ public function __set($name, $value)
* Magic get variable, do not call directly
* @param string $name
* @return string
* @throws \InvalidArgumentException
* @throws \WebLoader\InvalidArgumentException
*/
public function & __get($name)
{
if (array_key_exists($name, $this->variables)) {
return $this->variables[$name];
} else {
throw new \InvalidArgumentException("Variable '$name' is not set.");
throw new \WebLoader\InvalidArgumentException("Variable '$name' is not set.");
}
}

Expand Down
13 changes: 13 additions & 0 deletions InvalidArgumentException.php
@@ -0,0 +1,13 @@
<?php

namespace WebLoader;

/**
* InvalidArgumentException
*
* @author Jan Marek
*/
class InvalidArgumentException extends WebLoaderException
{

}
4 changes: 2 additions & 2 deletions Test/CompilerTest.php
Expand Up @@ -115,15 +115,15 @@ public function testFileFilters()
}

/**
* @expectedException \InvalidArgumentException
* @expectedException \WebLoader\InvalidArgumentException
*/
public function testNonCallableFilter()
{
$this->object->addFilter(4);
}

/**
* @expectedException \InvalidArgumentException
* @expectedException \WebLoader\InvalidArgumentException
*/
public function testNonCallableFileFilter()
{
Expand Down
2 changes: 2 additions & 0 deletions Test/bootstrap.php
@@ -1,6 +1,8 @@
<?php

require __DIR__ . '/../WebLoaderException.php';
require __DIR__ . '/../FileNotFoundException.php';
require __DIR__ . '/../InvalidArgumentException.php';
require __DIR__ . '/../IFileCollection.php';
require __DIR__ . '/../FileCollection.php';
require __DIR__ . '/../Compiler.php';
Expand Down
13 changes: 13 additions & 0 deletions WebLoaderException.php
@@ -0,0 +1,13 @@
<?php

namespace WebLoader;

/**
* WebLoaderException
*
* @author Jan Marek
*/
class WebLoaderException extends \Exception
{

}

0 comments on commit a196e2f

Please sign in to comment.