@@ -49,7 +49,7 @@ public function exceptionHandler(Throwable $exception): void
4949 * @param ExceptionItem|Throwable $exception
5050 * @return string
5151 */
52- protected function getErrorMessage (ExceptionItem |Throwable $ exception ): string
52+ public function getErrorMessage (ExceptionItem |Throwable $ exception ): string
5353 {
5454 if ($ exception instanceof Throwable) {
5555 $ exception = new ExceptionItem ($ exception );
@@ -70,7 +70,7 @@ protected function getErrorMessage(ExceptionItem|Throwable $exception): string
7070 }
7171
7272 $ message = preg_replace ('/[^\S\n]+/ ' , ' ' , (string )$ exception ->getMessage ());
73- if ($ exception ->getException () instanceof BlunderSoftException) {
73+ if ($ exception ->getException () instanceof BlunderSoftException) {
7474 return self ::ansi ()->style (["bold " , "red " ], "Notice: " ) . $ message ;
7575 }
7676 return sprintf (
@@ -86,6 +86,34 @@ protected function getErrorMessage(ExceptionItem|Throwable $exception): string
8686 )."\n" ;
8787 }
8888
89+ /**
90+ * Generate an small error message on one line
91+ *
92+ * @param ExceptionItem|Throwable $exception
93+ * @return string
94+ */
95+ public function getSmallErrorMessage (ExceptionItem |Throwable $ exception ): string
96+ {
97+ if ($ exception instanceof Throwable) {
98+ $ exception = new ExceptionItem ($ exception );
99+ }
100+
101+ $ msg = "\n" ;
102+ $ msg .= self ::ansi ()->red ("%s " ) . self ::ansi ()->italic ("(%s) " ) . ": " ;
103+ $ msg .= self ::ansi ()->bold ("%s " );
104+
105+ $ message = preg_replace ('/[^\S\n]+/ ' , ' ' , (string )$ exception ->getMessage ());
106+ if ($ exception ->getException () instanceof BlunderSoftException) {
107+ return self ::ansi ()->style (["bold " , "red " ], "Notice: " ) . $ message ;
108+ }
109+ return sprintf (
110+ $ msg ,
111+ get_class ($ exception ->getException ()),
112+ (string )$ exception ->getSeverityConstant (),
113+ $ message ,
114+ );
115+ }
116+
89117 /**
90118 * Get trace result
91119 * @param array $traceArr
0 commit comments