Documentation > Exceptions

This commit is contained in:
Meritoo
2018-07-02 09:31:07 +02:00
parent 834b24f348
commit a32e0c4cca
7 changed files with 75 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
# Meritoo Common Library
Common and useful classes, methods, exceptions etc.
# Base test case (with common methods and data providers)
@@ -45,6 +46,7 @@ class MimeTypesTest extends BaseTestCase
1. [**Base test case (with common methods and data providers)**](Base-test-case.md)
2. [Collection of elements](Collection-of-elements.md)
3. [Static methods](Static-methods.md)
3. [Exceptions](Exceptions.md)
4. [Static methods](Static-methods.md)
[‹ Back to `Readme`](../README.md)

View File

@@ -1,4 +1,5 @@
# Meritoo Common Library
Common and useful classes, methods, exceptions etc.
# Collection of elements
@@ -43,6 +44,7 @@ var_dump($simpleCollection->has('dolor')); // bool(true)
1. [Base test case (with common methods and data providers)](Base-test-case.md)
2. [**Collection of elements**](Collection-of-elements.md)
3. [Static methods](Static-methods.md)
3. [Exceptions](Exceptions.md)
4. [Static methods](Static-methods.md)
[‹ Back to `Readme`](../README.md)

View File

@@ -1,4 +1,5 @@
# Meritoo Common Library
Development-related information
# Requirements

61
docs/Exceptions.md Normal file
View File

@@ -0,0 +1,61 @@
# Meritoo Common Library
Common and useful classes, methods, exceptions etc.
# Exceptions
### Create instance of exception
This package contains a lot of exceptions. Each of them contains static method `create()` with proper arguments that is used to create instance of the exception. Example:
```php
use Meritoo\Common\Exception\Bundle\IncorrectBundleNameException;
throw IncorrectBundleNameException::create('RisusIpsum');
```
### Base exception for unknown type of something
##### Short description
It's a `Meritoo\Common\Exception\Base\UnknownTypeException` class. Related to `Meritoo\Common\Type\Base\BaseType` class that represents type of something, e.g. type of button, order.
##### Usage
You can extend `Meritoo\Common\Exception\Base\UnknownTypeException` class and create your own static method, e.g. `createException()`, which will be used create instance of the exception. Inside the `createException()` method you can call `parent::create()` method.
##### Example
```php
<?php
namespace Your\Package\Exception\Type;
use Meritoo\Common\Exception\Base\UnknownTypeException;
use Your\Package\Type\SimpleType;
class UnknownSimpleTypeException extends UnknownTypeException
{
/**
* Creates exception
*
* @param string $unknownType Unknown and simple type
* @return UnknownSimpleTypeException
*/
public static function createException($unknownType)
{
/* @var UnknownSimpleTypeException $exception */
$exception = parent::create($unknownType, new SimpleType(), 'my simple type of something');
return $exception;
}
}
```
# More
1. [Base test case (with common methods and data providers)](Base-test-case.md)
2. [Collection of elements](Collection-of-elements.md)
3. [**Exceptions**](Exceptions.md)
4. [Static methods](Static-methods.md)
[&lsaquo; Back to `Readme`](../README.md)

View File

@@ -1,4 +1,5 @@
# Meritoo Common Library
Common and useful classes, methods, exceptions etc.
# Static methods
@@ -16,6 +17,7 @@ var_dump($firstElement); // string(5) "lorem"
1. [Base test case (with common methods and data providers)](Base-test-case.md)
2. [Collection of elements](Collection-of-elements.md)
3. [**Static methods**](Static-methods.md)
3. [Exceptions](Exceptions.md)
4. [**Static methods**](Static-methods.md)
[&lsaquo; Back to `Readme`](../README.md)