Jelajahi Sumber

Added FormattedException to base file

Taddeus Kroes 13 tahun lalu
induk
melakukan
b646dfc0c1
1 mengubah file dengan 18 tambahan dan 1 penghapusan
  1. 18 1
      base.php

+ 18 - 1
base.php

@@ -66,12 +66,29 @@ abstract class Base {
 	}
 }
 
+/**
+ * Exception with sprintf()-like constructor for error message formatting.
+ * 
+ * @package WebBasics
+ * @link http://php.net/sprintf
+ */
+class FormattedException extends \Exception {
+	/**
+	 * Constructor, sets a formatted error message.
+     * @link http://php.net/sprintf
+	 */
+	function __construct() {
+		$args = func_get_args();
+		$this->message = call_user_func_array('sprintf', $args);
+	}
+}
+
 /**
  * Exception, thrown when a required file does not exist.
  * 
  * @package WebBasics
  */
-class FileNotFoundError extends \RuntimeException {
+class FileNotFoundError extends \Exception {
 	/**
 	 * Create a new FileNotFoundError instance.
 	 *