update to PHP-8.1
[m6w6/seekat] / lib / Exception / functions.php
index 9045cb3df3473f1f41df7a9422fb5f4a8c37b432..1930ad091713419d28ed3766328c83a1cdf9caf7 100644 (file)
@@ -2,12 +2,14 @@
 
 namespace seekat\Exception;
 
+use Throwable;
+
 /**
- * @param $message
- * @return \Throwable
+ * @param string|Throwable $message
+ * @return Throwable
  */
-function exception(&$message) : \Throwable {
-       if ($message instanceof \Throwable){
+function exception(&$message) : Throwable {
+       if ($message instanceof Throwable){
                $exception = $message;
                $message = $exception->getMessage();
        } else {
@@ -18,11 +20,10 @@ function exception(&$message) : \Throwable {
 
 /**
  * Canonical error message from a string or Exception
- * @param string|Exception $error
- * @return string
+ * @param string|Throwable $error
  */
-function message(&$error) : string {
-       if ($error instanceof \Throwable) {
+function message(&$error) : ?string {
+       if ($error instanceof Throwable) {
                $message = $error->getMessage();
        } else {
                $message = $error;