4
4
5
5
namespace Okvpn \Bundle \DatadogBundle \Tests \Functional \App \Command ;
6
6
7
+ use Psr \Log \LoggerInterface ;
7
8
use Symfony \Component \Console \Command \Command ;
8
9
use Symfony \Component \Console \Input \InputInterface ;
10
+ use Symfony \Component \Console \Input \InputOption ;
9
11
use Symfony \Component \Console \Output \OutputInterface ;
10
12
11
13
class DatadogExceptionCommand extends Command
12
14
{
15
+ private $ logger ;
16
+
17
+ public function __construct (LoggerInterface $ logger )
18
+ {
19
+ $ this ->logger = $ logger ;
20
+ parent ::__construct ();
21
+ }
22
+
13
23
/**
14
24
* {@inheritdoc}
15
25
*/
16
26
protected function configure ()
17
27
{
18
28
$ this
19
29
->setName ('app:exception ' )
30
+ ->addOption ('filter ' , null , InputOption::VALUE_OPTIONAL )
20
31
->setDescription ('Trigger error ' );
21
32
}
22
33
@@ -25,6 +36,26 @@ protected function configure()
25
36
*/
26
37
protected function execute (InputInterface $ input , OutputInterface $ output )
27
38
{
28
- \function_do_not_exists ();
39
+ switch ($ input ->getOption ('filter ' )) {
40
+ case 'skip_instanceof ' :
41
+ throw new DemoDatadogException ('Test datadog handle exception ' );
42
+ break ;
43
+ case 'skip_capture ' :
44
+ throw new \UnderflowException ('Test datadog handle exception ' );
45
+ break ;
46
+ case 'skip_wildcard ' :
47
+ throw new \RuntimeException ('Loading of entity aliases failed ' );
48
+ break ;
49
+ case 'test_logger ' :
50
+ $ exception = new \RuntimeException ('Logger exception ' );
51
+ $ this ->logger ->error ('Unhatched exception ' , ['exception ' => $ exception ]);
52
+ break ;
53
+ case 'test_logger_wildcard ' :
54
+ $ exception = new \RuntimeException ('Logger exception ' );
55
+ $ this ->logger ->error ('Loading of entity aliases failed ' , ['exception ' => $ exception ]);
56
+ break ;
57
+ default :
58
+ \function_do_not_exists ();
59
+ }
29
60
}
30
61
}
0 commit comments