Skip to content

Commit

Permalink
Merge branch 'release/v0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Aug 23, 2019
2 parents 25bb993 + c3df7e3 commit 48fec0f
Show file tree
Hide file tree
Showing 31 changed files with 3,762 additions and 93 deletions.
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Amazeballs {

public function doStuff() {
throw \Glitch::{'ENotFound,EFailedService'}(
'Server "doStuff" cannot be found'
'Service "doStuff" cannot be found'
);
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ composer require decodelabs/glitch
Register base paths for easier reading of file names

```php
\Glitch\PathHandler::registerAlias('app', '/path/to/my/app');
\Glitch\Context::getDefault()->registerPathAlias('app', '/path/to/my/app');

/*
/path/to/my/app/models/MyModel.php
Expand All @@ -129,7 +129,7 @@ becomes

### Usage

Throw Glitches rather than Exceptions, passing mixed in interfaces as the method name (error interfaces must begin with E)
Throw Glitches rather than Exceptions, passing mixed in interfaces as the method name (generated error interfaces must begin with E)

```php
throw \Glitch::EOutOfBounds('This is out of bounds');
Expand All @@ -139,13 +139,31 @@ throw \Glitch::{'ENotFound,EBadMethodCall'}(
);

// You can associate a http code too..
throw \Glitch::ECompletelyMadeUpMeaning([
'message' => 'My message',
throw \Glitch::ECompletelyMadeUpMeaning('My message', [
'code' => 1234,
'http' => 501
]);

throw \Glitch::{'EInvalidArgument,Psr\\Cache\\InvalidArgumentException'}(
'Cache items must implement Cache\\IItem',
['http' => 500], // params
$item // data
);
```

Catch a Glitch in the normal way using whichever scope you require:

```php
try {
throw \Glitch::{'ENotFound,EBadMethodCall'}(
'Didn\'t find a thing, couldn\'t call the other thing'
);
} catch(\EGlitch | \ENotFound | MyLibrary\EGlitch | MyLibrary\AThingThatDoesStuff\EBadMethodCall $e) {
// All these types will catch
}
```



## Licensing
Glitch is licensed under the MIT License. See [LICENSE](https://github.com/decodelabs/glitch/blob/master/LICENSE) for the full license text.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
}
],
"require": {
"php": "^7.1.3",
"decodelabs/df-base": "dev-develop"
"php": "^7.2",
"symfony/polyfill-mbstring": "~1.7",

"components/jquery": "~3.3",
"components/bootstrap": "~4.3"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 48fec0f

Please sign in to comment.