Skip to content

Commit f688077

Browse files
committed
ICL: Custom exceptions with context readme info added.
1 parent 6fb1f9d commit f688077

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,47 @@ array:4 [
110110
[2016-05-11 17:19:21]: [INFO]: Memory peak usage: 8 MB.
111111
```
112112
113+
If you want to pass additional context to your custom exception, use `Illuminated\Console\RuntimeException`:
114+
115+
```php
116+
class Foo extends Command
117+
{
118+
use Loggable;
119+
120+
public function handle()
121+
{
122+
throw new RuntimeException('Oooups! Houston, we have a problem!', [
123+
'some' => 123,
124+
'extra' => true,
125+
'context' => null,
126+
]);
127+
}
128+
129+
// ...
130+
}
131+
```
132+
133+
```
134+
[2016-05-11 17:19:21]: [INFO]: Command `App\Console\Commands\Foo` initialized.
135+
[2016-05-11 17:19:21]: [INFO]: Host: `MyHost.local` (`10.0.1.1`).
136+
[2016-05-11 17:19:21]: [INFO]: Database host: `MyHost.local`, port: `3306`, ip: ``.
137+
[2016-05-11 17:19:21]: [INFO]: Database date: `2016-05-11 17:19:21`.
138+
[2016-05-11 17:19:21]: [ERROR]: Oooups! Houston, we have a problem!
139+
array:5 [
140+
"code" => 0
141+
"message" => "Oooups! Houston, we have a problem!"
142+
"file" => "/Applications/MAMP/htdocs/illuminated-console-logger-test/app/Console/Commands/Foo.php"
143+
"line" => 22
144+
"context" => array:3 [
145+
"some" => 123
146+
"extra" => true
147+
"context" => null
148+
]
149+
]
150+
[2016-05-11 17:19:21]: [INFO]: Execution time: 0.017 sec.
151+
[2016-05-11 17:19:21]: [INFO]: Memory peak usage: 8 MB.
152+
```
153+
113154
## Auto saving to DB
114155
115156
In progress...

0 commit comments

Comments
 (0)