@@ -29,26 +29,50 @@ public function __construct(HubInterface $hub, ?Connection $connection = null)
2929
3030 public function pingDatabase (): Response
3131 {
32- $ this ->hub ->setSpan (
33- $ this ->hub ->getSpan ()
34- ->startChild ($ this ->createSpan ())
35- );
32+ try {
33+ $ this ->hub ->setSpan (
34+ $ this ->hub ->getSpan ()
35+ ->startChild ($ this ->createSpan ())
36+ );
3637
37- if ($ this ->connection ) {
38- $ this ->connection ->executeQuery ('SELECT 1 ' );
39- }
38+ if ($ this ->connection ) {
39+ $ this ->connection ->executeQuery ('SELECT 1 ' );
40+ }
41+
42+ return new Response ('Success ' );
43+ } catch (\Throwable $ e ) {
44+ $ errorMessage = sprintf (
45+ "Exception: %s \nMessage: %s \nFile: %s \nLine: %d " ,
46+ get_class ($ e ),
47+ $ e ->getMessage (),
48+ $ e ->getFile (),
49+ $ e ->getLine ()
50+ );
4051
41- return new Response ('Success ' );
52+ return new Response ($ errorMessage , 200 );
53+ }
4254 }
4355
4456 public function ignoredTransaction (): Response
4557 {
46- $ this ->hub ->setSpan (
47- $ this ->hub ->getSpan ()
48- ->startChild ($ this ->createSpan ())
49- );
58+ try {
59+ $ this ->hub ->setSpan (
60+ $ this ->hub ->getSpan ()
61+ ->startChild ($ this ->createSpan ())
62+ );
5063
51- return new Response ('Success ' );
64+ return new Response ('Success ' );
65+ } catch (\Throwable $ e ) {
66+ $ errorMessage = sprintf (
67+ "Exception: %s \nMessage: %s \nFile: %s \nLine: %d " ,
68+ get_class ($ e ),
69+ $ e ->getMessage (),
70+ $ e ->getFile (),
71+ $ e ->getLine ()
72+ );
73+
74+ return new Response ($ errorMessage , 200 );
75+ }
5276 }
5377
5478 private function createSpan (): SpanContext
0 commit comments