diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2013-06-01 20:10:36 -0500 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2013-06-01 20:10:36 -0500 |
commit | 951330c9f83c8c8ee98f65fdccb5797e2e59d1f3 (patch) | |
tree | fc7b196ca0d91c1c71dcd945aa9667c7af0134fa /includes/HybridAuth/Error.php | |
parent | e58a3b8b3702b22c903b02a9b4fa1020d6797459 (diff) | |
download | pathery-951330c9f83c8c8ee98f65fdccb5797e2e59d1f3.tar.xz |
A partial commit of the auth stuff, in case my upcoming changes break anything
Diffstat (limited to 'includes/HybridAuth/Error.php')
-rw-r--r-- | includes/HybridAuth/Error.php | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/includes/HybridAuth/Error.php b/includes/HybridAuth/Error.php new file mode 100644 index 0000000..d8349b0 --- /dev/null +++ b/includes/HybridAuth/Error.php @@ -0,0 +1,84 @@ +<?php +/*! +* HybridAuth +* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth +* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html +*/ + +/** + * Errors manager + * + * HybridAuth errors are stored in Hybrid::storage() and not displayed directly to the end user + */ +class Hybrid_Error +{ + /** + * store error in session + */ + public static function setError( $message, $code = NULL, $trace = NULL, $previous = NULL ) + { + Hybrid_Logger::info( "Enter Hybrid_Error::setError( $message )" ); + + Hybrid_Auth::storage()->set( "hauth_session.error.status" , 1 ); + Hybrid_Auth::storage()->set( "hauth_session.error.message" , $message ); + Hybrid_Auth::storage()->set( "hauth_session.error.code" , $code ); + Hybrid_Auth::storage()->set( "hauth_session.error.trace" , $trace ); + Hybrid_Auth::storage()->set( "hauth_session.error.previous", $previous ); + } + + /** + * clear the last error + */ + public static function clearError() + { + Hybrid_Logger::info( "Enter Hybrid_Error::clearError()" ); + + Hybrid_Auth::storage()->delete( "hauth_session.error.status" ); + Hybrid_Auth::storage()->delete( "hauth_session.error.message" ); + Hybrid_Auth::storage()->delete( "hauth_session.error.code" ); + Hybrid_Auth::storage()->delete( "hauth_session.error.trace" ); + Hybrid_Auth::storage()->delete( "hauth_session.error.previous" ); + } + + /** + * Checks to see if there is a an error. + * + * @return boolean True if there is an error. + */ + public static function hasError() + { + return (bool) Hybrid_Auth::storage()->get( "hauth_session.error.status" ); + } + + /** + * return error message + */ + public static function getErrorMessage() + { + return Hybrid_Auth::storage()->get( "hauth_session.error.message" ); + } + + /** + * return error code + */ + public static function getErrorCode() + { + return Hybrid_Auth::storage()->get( "hauth_session.error.code" ); + } + + /** + * return string detailled error backtrace as string. + */ + public static function getErrorTrace() + { + return Hybrid_Auth::storage()->get( "hauth_session.error.trace" ); + } + + /** + * @return string detailled error backtrace as string. + */ + public static function getErrorPrevious() + { + return Hybrid_Auth::storage()->get( "hauth_session.error.previous" ); + } +} |