[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gforge-commits] gforge/common/include Error.class,1.7,1.8
From: |
gsmet |
Subject: |
[Gforge-commits] gforge/common/include Error.class,1.7,1.8 |
Date: |
Sun, 12 Sep 2004 12:42:29 -0500 |
Update of /cvsroot/gforge/gforge/common/include
In directory db.perdue.net:/tmp/cvs-serv7851/common/include
Modified Files:
Error.class
Log Message:
improved Error.class thanks to an idea of Hidenari Miwa (see [#742])
Index: Error.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/include/Error.class,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Error.class 16 Apr 2004 19:44:46 -0000 1.7
+++ Error.class 12 Sep 2004 17:42:26 -0000 1.8
@@ -26,6 +26,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+define('ERROR__NO_ERROR', 0);
+define('ERROR__UNCLASSIFIED_ERROR', 1);
+define('ERROR__PERMISSION_DENIED_ERROR', 2);
+define('ERROR__INVALID_EMAIL_ERROR', 3);
+define('ERROR__ON_UPDATE_ERROR', 4);
+define('ERROR__GROUPID_ERROR', 5);
+define('ERROR__MISSING_PARAMS_ERROR', 6);
+
class Error {
/**
* The current error state.
@@ -42,6 +50,13 @@
var $error_message;
/**
+ * The current error code
+ *
+ * @var int $error_code.
+ */
+ var $error_code;
+
+ /**
* Error() - Constructor.
* Constructor for the Error class.
* Sets the error state to false.
@@ -50,19 +65,21 @@
function Error() {
//nothing
$this->error_state=false;
+ $this->error_code=ERROR__NO_ERROR;
}
/**
* setError() - Sets the error string.
* Set the error string $error_message to the value of $string
- # and enable the $error_state flag.
+ * and enable the $error_state flag.
*
* @param string The error string to set.
- *
+ * @param int The error code
*/
- function setError($string) {
+ function setError($string, $code=ERROR__UNCLASSIFIED_ERROR) {
$this->error_state=true;
$this->error_message=$string;
+ $this->error_code=$code;
}
/**
@@ -72,6 +89,7 @@
*/
function clearError() {
$this->error_state=false;
+ $this->error_code=ERROR__NO_ERROR;
$this->error_message='';
}
@@ -110,60 +128,94 @@
*/
function setPermissionDeniedError(){
global $Language;
- $this->setError($Language->getText('general','permdenied'));
+ $this->setError($Language->getText('general','permdenied'),
ERROR__PERMISSION_DENIED_ERROR);
+ }
+
+ /**
+ * isPermissionDeniedError() - Determines if it is a permission denied
error
+ *
+ * @return boolean
+ */
+ function isPermissionDeniedError(){
+ return ($this->error_code == ERROR__PERMISSION_DENIED_ERROR);
}
/**
* setInvalidEmailError() - sets a Invalid Email error
* retrieves the localized error string for Invalid Email and calls
exit_error()
- *
- *
*/
function setInvalidEmailError(){
global $Language;
- $this->setError($Language->getText('general','invalid_email'));
+ $this->setError($Language->getText('general','invalid_email'),
ERROR__INVALID_EMAIL_ERROR);
+ }
+
+ /**
+ * isInvalidEmailError() - Determines if it is an invalid email error
+ *
+ * @return boolean
+ */
+ function isInvalidEmailError(){
+ return ($this->error_code == ERROR__INVALID_EMAIL_ERROR);
}
/**
* setOnUpdateError() - sets an On Update Error
- * retrieves the localized error string for On Update and calls
exit_error()
+ * retrieves the localized error string for On Update
*
- * * @param string The db result to be written.
+ * @param string The db result to be written.
*
*/
-
function setOnUpdateError($result=""){
global $Language;
-
$this->setError($Language->getText('general','error_on_update',$result));
-
+
$this->setError($Language->getText('general','error_on_update',$result),
ERROR__ON_UPDATE_ERROR);
}
-
+
/**
- * setGroupIdError() - sets an Group ID Error
- * retrieves the localized error string for Group ID and calls
exit_error()
- *
+ * isOnUpdateError() - Determines if it is an on update error
*
+ * @return boolean
*/
+ function isOnUpdateError(){
+ return ($this->error_code == ERROR__ON_UPDATE_ERROR);
+ }
+ /**
+ * setGroupIdError() - sets an Group ID Error
+ * retrieves the localized error string for Group ID
+ */
function setGroupIdError(){
global $Language;
- $this->setError($Language->getText('general','error_group_id'));
+ $this->setError($Language->getText('general','error_group_id'),
ERROR__GROUPID_ERROR);
}
-
+
/**
- * setMissingParamsError() - sets an Group ID Error
- * retrieves the localized error string for missing pparamsand calls
exit_error()
- *
+ * isGroupIdError() - Determines if it is a group ID error
*
+ * @return boolean
*/
+ function isGroupIdError(){
+ return ($this->error_code == ERROR__GROUPID_ERROR);
+ }
+ /**
+ * setMissingParamsError() - sets an Group ID Error
+ * retrieves the localized error string for missing pparams
+ */
function setMissingParamsError(){
global $Language;
-
$this->setError($Language->getText('general','error_missing_params'));
-
+
$this->setError($Language->getText('general','error_missing_params'),
ERROR__MISSING_PARAMS_ERROR);
+ }
+
+ /**
+ * isMissingParamsError() - Determines if it is a missing params error
+ *
+ * @return boolean
+ */
+ function isMissingParamsError(){
+ return ($this->error_code == ERROR__MISSING_PARAMS_ERROR);
}
}
-?>
+?>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gforge-commits] gforge/common/include Error.class,1.7,1.8,
gsmet <=