Skip to content

Commit

Permalink
Added some more exception classes.
Browse files Browse the repository at this point in the history
Reorganized the namespace structure.
Updated readme.
  • Loading branch information
Martin Brecht-Precht committed Apr 26, 2016
1 parent 4ca0113 commit 826b6f2
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 31 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ require_once('path/to/vendor/autoload.php');
```{php}
try{
// Perform something maybe throwing an exception
} catch (CommonException\ApiException\NetworkException $exception) {
// API is not reachable or curl failed
} catch (CommonException\ApiException\ApiException $exception) {
} catch (CommonException\NetworkException\ConnectionException $exception) {
// API is not reachable
} catch (CommonException\NetworkException\CurlException $exception) {
// Curl failed
} catch (CommonException\ApiException\InvalidResponseException $exception) {
// API returns an unexpected result
} catch (CommonException\ApiException\ApiLimitException $exception) {
} catch (CommonException\ApiException\RequestQuotaException $exception) {
// API requests over the allowed limit
} catch (CommonException\ApiException\ApiNoResultsException $exception) {
} catch (CommonException\ApiException\NoResultsException $exception) {
// API request had no result
} catch (CommonException\IoException\FileWriteException $exception) {
// Log file was not writable
Expand All @@ -53,9 +55,11 @@ try{
```{php}
try{
// Perform something maybe throwing an exception
} catch (CommonException\ApiException\Base\BaseException $exception) {
} catch (CommonException\NetworkException\Base\NetworkException $exception) {
// Any network exception was thrown
} catch (CommonException\ApiException\Base\ApiException $exception) {
// Any API exception was thrown
} catch (CommonException\IoException\Base\BaseException $exception) {
} catch (CommonException\IoException\Base\IoException $exception) {
// Any IO exception was thrown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace CommonException\ApiException;

/**
* Class ApiNoResultsException
* Class AuthenticationException
*
* @package CommonException\ApiException
*/
class ApiNoResultsException extends Base\BaseException
class AuthenticationException extends Base\ApiException
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace CommonException\ApiException;
namespace CommonException\ApiException\Base;

use CommonException\Base;

/**
* Class ApiException
Expand Down
15 changes: 0 additions & 15 deletions src/ApiException/Base/BaseException.php

This file was deleted.

13 changes: 13 additions & 0 deletions src/ApiException/InvalidResponseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\ApiException;

/**
* Class InvalidResponseException
*
* @package CommonException\ApiException
*/
class InvalidResponseException extends Base\ApiException
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace CommonException\ApiException;

/**
* Class ApiLimitException
* Class NoResultsException
*
* @package CommonException\ApiException
*/
class ApiLimitException extends Base\BaseException
class NoResultsException extends Base\ApiException
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace CommonException\ApiException;

/**
* Class NetworkException
* Class RequestQuotaException
*
* @package CommonException\ApiException
*/
class NetworkException extends Base\BaseException
class RequestQuotaException extends Base\ApiException
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @package CommonException\IoException\Base
*/
abstract class BaseException extends Base\BaseException
class IoException extends Base\BaseException
{

}
13 changes: 13 additions & 0 deletions src/IoException/FileCopyException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\IoException;

/**
* Class FileCopyException
*
* @package CommonException\IoException
*/
class FileCopyException extends Base\IoException
{

}
13 changes: 13 additions & 0 deletions src/IoException/FileDeleteException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\IoException;

/**
* Class FileDeleteException
*
* @package CommonException\IoException
*/
class FileDeleteException extends Base\IoException
{

}
13 changes: 13 additions & 0 deletions src/IoException/FileMoveException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\IoException;

/**
* Class FileMoveException
*
* @package CommonException\IoException
*/
class FileMoveException extends Base\IoException
{

}
13 changes: 13 additions & 0 deletions src/IoException/FileReadException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\IoException;

/**
* Class FileReadException
*
* @package CommonException\IoException
*/
class FileReadException extends Base\IoException
{

}
2 changes: 1 addition & 1 deletion src/IoException/FileWriteException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @package CommonException\IoException
*/
class FileWriteException extends Base\BaseException
class FileWriteException extends Base\IoException
{

}
15 changes: 15 additions & 0 deletions src/NetworkException/Base/NetworkException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace CommonException\NetworkException\Base;

use CommonException\Base;

/**
* Class NetworkException
*
* @package CommonException\NetworkException\Base
*/
class NetworkException extends Base\BaseException
{

}
13 changes: 13 additions & 0 deletions src/NetworkException/Base/TimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\NetworkException\Base;

/**
* Class TimeoutException
*
* @package CommonException\NetworkException\Base
*/
class TimeoutException extends NetworkException
{

}
13 changes: 13 additions & 0 deletions src/NetworkException/ConnectionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\NetworkException;

/**
* Class ConnectionException
*
* @package CommonException\NetworkException
*/
class ConnectionException extends Base\NetworkException
{

}
13 changes: 13 additions & 0 deletions src/NetworkException/ConnectionTimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\NetworkException;

/**
* Class ConnectionTimeoutException
*
* @package CommonException\NetworkException
*/
class ConnectionTimeoutException extends Base\TimeoutException
{

}
13 changes: 13 additions & 0 deletions src/NetworkException/CurlException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\NetworkException;

/**
* Class CurlException
*
* @package CommonException\NetworkException
*/
class CurlException extends Base\NetworkException
{

}
13 changes: 13 additions & 0 deletions src/NetworkException/ReadTimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\NetworkException;

/**
* Class ReadTimeoutException
*
* @package CommonException\NetworkException
*/
class ReadTimeoutException extends Base\TimeoutException
{

}
13 changes: 13 additions & 0 deletions src/NetworkException/WriteTimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommonException\NetworkException;

/**
* Class WriteTimeoutException
*
* @package CommonException\NetworkException
*/
class WriteTimeoutException extends Base\TimeoutException
{

}

0 comments on commit 826b6f2

Please sign in to comment.