From cd813406faefd6327984d11da7eb53e84761c450 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 15 Sep 2008 07:36:24 +0000
Subject: [PATCH] Utilities - add function to get last error message.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@868 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Utilities.php | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 188ea4854..4f29a96d2 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -1365,6 +1365,30 @@ class SimpleSAML_Utilities {
 		return $secretSalt;
 	}
 
+
+	/**
+	 * Retrieve last error message.
+	 *
+	 * This function retrieves the last error message. If no error has occured,
+	 * '[No error message found]' will be returned. If the required function isn't available,
+	 * '[Cannot get error message]' will be returned.
+	 *
+	 * @return string  Last error message.
+	 */
+	public static function getLastError() {
+
+		if (!function_exists('error_get_last')) {
+			return '[Cannot get error message]';
+		}
+
+		$error = error_get_last();
+		if ($error === NULL) {
+			return '[No error message found]';
+		}
+
+		return $error['message'];
+	}
+
 }
 
 ?>
\ No newline at end of file
-- 
GitLab