Index: openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl,v diff -u -N -r1.90 -r1.91 --- openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl 7 Aug 2017 23:47:46 -0000 1.90 +++ openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl 29 Dec 2017 10:46:39 -0000 1.91 @@ -229,7 +229,7 @@ } } - with_catch errmsg { + ad_ty { array set result [auth::authentication::Authenticate \ -username $username \ -authority_id $authority_id \ @@ -240,10 +240,10 @@ if {$result(auth_status) eq "ok"} { set dummy $result(account_status) } - } { + } on error {errorMsg} { set result(auth_status) failed_to_connect - set result(auth_message) $errmsg - ns_log Error "auth::authenticate: error invoking authentication driver for authority_id = $authority_id: $::errorInfo" + set result(auth_message) $errorMsg + ad_log Error "auth::authenticate: error invoking authentication driver for authority_id = $authority_id: $::errorInfo" } # Returns: @@ -624,8 +624,8 @@ } on_error { set creation_info(creation_status) failed_to_connect - set creation_info(creation_message) $errmsg - ns_log Error "auth::create_user: Error invoking account registration driver for authority_id = $authority_id: $::errorInfo" + set creation_info(creation_message) $errorMsg + ad_log Error "auth::create_user: Error invoking account registration driver for authority_id = $authority_id" } if { $creation_info(creation_status) ne "ok" } { @@ -973,7 +973,7 @@ } set error_p 0 - with_catch errmsg { + ad_try { # We create the user without a password # If it's a local account, that'll get set later set user_id [auth::create_local_account_helper \ @@ -997,14 +997,14 @@ -person_id $user_id \ -bio $user_info(bio) } - } { + } on error {errorMsg} { set error_p 1 } if { $error_p || $user_id == 0 } { set result(creation_status) "failed_to_connect" set result(creation_message) [_ acs-subsite.Error_trying_to_register] - ns_log Error "auth::create_local_account: Error creating local account.\n$::errorInfo" + ad_log Error "auth::create_local_account: Error creating local account." return [array get result] } @@ -1023,10 +1023,10 @@ set result(account_status) "closed" set result(account_message) "

[_ acs-subsite.lt_Registration_informat_1]

[_ acs-subsite.lt_Please_read_and_follo]

" - with_catch errmsg { + ad_try { auth::send_email_verification_email -user_id $user_id - } { - ns_log Error "auth::create_local_account: Error sending out email verification email to email $email:\n$::errorInfo" + } on error {errorMsg} { + ad_log Error "auth::create_local_account: Error sending out email verification email to email $email: $errorMsg" set auth_info(account_message) [_ acs_subsite.Error_sending_verification_mail] } } @@ -1076,9 +1076,11 @@ # This may fail, either because there's no connection, or because # we're in the bootstrap-installer, at which point [ad_conn user_id] is undefined. - catch { + ad_try { set creation_user [ad_conn user_id] set peeraddr [ad_conn peeraddr] + } on error {errorMsg} { + ns_log warning "auth::create_local_account_helper $errorMsg" } set salt [sec_random_token] @@ -1092,17 +1094,18 @@ # set password_question, password_answer db_dml update_question_answer {} - if {[catch { + ad_try { # Call the extension acs_user_extension::user_new -user_id $user_id - } errmsg]} { + } on error {errorMsg} { # At this point, we don't want the user addition to fail # if some extension is screwing things up + ns_log warning "acs_user_extension::user_new -user_id $user_id failed: $errorMsg" } } on_error { # we got an error. log it and signal failure. - ns_log Error "Problem creating a new user: $::errorInfo" + ad_log Error "Problem creating a new user" set error_p 1 } @@ -1170,8 +1173,7 @@ set user_id $user_info(user_id) set result(user_id) $user_id - set error_p 0 - with_catch errmsg { + ad_try { db_transaction { # Update persons: first_names, last_name @@ -1230,14 +1232,10 @@ # TODO: Portrait } - } { - set error_p 1 - } - - if { $error_p } { + } on error {errorMsg} { set result(update_status) "failed_to_connect" set result(update_message) [_ acs-subsite.Error_update_account_info] - ns_log Error "Error updating local account.\n$::errorInfo" + ad_log Error "Error updating local account: $errorMsg" return [array get result] } @@ -1343,10 +1341,10 @@ set authority_id [auth::authority::local] } #ns_log notice "auth::get_local_account authority_id = '${authority_id}' local = [auth::authority::local]" - with_catch errmsg { + ad_try { acs_user::get -authority_id $authority_id -username $username -array user set account_found_p 1 - } { + } on error {errorMsg} { set account_found_p 0 } if { !$account_found_p } { @@ -1472,10 +1470,10 @@ if { !$no_dialogue_p } { set result(account_message) "

[_ acs-subsite.lt_Registration_informat]

[_ acs-subsite.lt_Please_read_and_follo]

" - with_catch errmsg { + ad_try { auth::send_email_verification_email -user_id $user_id - } { - ns_log Error "auth::check_local_account_status: Error sending out email verification email to email $email:\n$::errorInfo" + } on error {errorMsg} { + ad_log Error "auth::check_local_account_status: Error sending out email verification email to email $email: $errorMsg" set result(account_message) [_ acs-subsite.Error_sending_verification_mail] } } @@ -1524,7 +1522,7 @@ Return 'ok', 'closed', or 'no_account' } { set result no_account - catch { + ad_try { acs_user::get -user_id $user_id -array user array set check_result [auth::check_local_account_status \ -user_id $user_id \ @@ -1534,6 +1532,8 @@ -password_age_days $user(password_age_days)] set result $check_result(account_status) + } on error {errorMsg} { + ns_log notice "auth::get_local_account_status returned: $errorMsg" } return $result } Index: openacs-4/packages/acs-authentication/tcl/authority-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/authority-procs.tcl,v diff -u -N -r1.30 -r1.31 --- openacs-4/packages/acs-authentication/tcl/authority-procs.tcl 7 Aug 2017 23:47:46 -0000 1.30 +++ openacs-4/packages/acs-authentication/tcl/authority-procs.tcl 29 Dec 2017 10:46:39 -0000 1.31 @@ -323,12 +323,12 @@ document {} snapshot_p f } - with_catch errmsg { + ad_try { array set doc_result [auth::sync::GetDocument -authority_id $authority_id] - } { - ns_log Error "Error getting sync document:\n$::errorInfo" + } on error {errorMsg} { + ad_log Error "Error getting sync document: errorMsg" set doc_result(doc_status) failed_to_connect - set doc_result(doc_message) $errmsg + set doc_result(doc_message) $errorMsg } set snapshot_p [template::util::is_true $doc_result(snapshot_p)] @@ -341,7 +341,7 @@ -snapshot=$snapshot_p if { $doc_result(doc_status) eq "ok" && $doc_result(document) ne "" } { - with_catch errmsg { + ad_try { auth::sync::ProcessDocument \ -authority_id $authority_id \ -job_id $job_id \ @@ -371,9 +371,9 @@ $ack_file_name \ $ack_doc } - } { - ns_log Error "Error processing sync document:\n$::errorInfo" - set message "Error processing sync document: $errmsg" + } on error {errorMsg} { + ad_log Error "Error processing sync document: $errorMsg" + set message "Error processing sync document: $errorMsg" } } else { if { $message eq "" } { Index: openacs-4/packages/acs-authentication/tcl/driver-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/driver-procs.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/acs-authentication/tcl/driver-procs.tcl 29 Dec 2017 10:05:27 -0000 1.9 +++ openacs-4/packages/acs-authentication/tcl/driver-procs.tcl 29 Dec 2017 10:46:39 -0000 1.10 @@ -31,13 +31,13 @@ set parameters {} - with_catch errmsg { + ad_try { set parameters [acs_sc::invoke \ -error \ -impl_id $impl_id \ -operation GetParameters] - } { - ns_log Error "Error getting parameters for impl_id $impl_id: $errmsg\n$::errorInfo" + } on error {errorMsg} { + ad_log Error "Error getting parameters for impl_id $impl_id: $errorMsg" } return $parameters } Index: openacs-4/packages/acs-authentication/tcl/local-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/local-procs.tcl,v diff -u -N -r1.40 -r1.41 --- openacs-4/packages/acs-authentication/tcl/local-procs.tcl 7 Aug 2017 23:47:46 -0000 1.40 +++ openacs-4/packages/acs-authentication/tcl/local-procs.tcl 29 Dec 2017 10:46:39 -0000 1.41 @@ -276,16 +276,18 @@ } } - if { [catch { ad_change_password $user_id $new_password } errmsg] } { + ad_try { + ad_change_password $user_id $new_password + } on error {errorMsg} { set result(password_status) "change_error" - ns_log Error "Error changing local password for username $username, user_id $user_id: \n$::errorInfo" + ad_log Error "Error changing local password for username $username, user_id $user_id: $errorMsg" return [array get result] } set result(password_status) "ok" if { [parameter::get -parameter EmailAccountOwnerOnPasswordChangeP -package_id [ad_acs_kernel_id] -default 1] } { - with_catch errmsg { + ad_try { acs_user::get -username $username -authority_id $authority_id -array user set system_name [ad_system_name] @@ -304,13 +306,13 @@ set body [_ acs-subsite.Password_changed_body] acs_mail_lite::send \ - -send_immediately \ - -to_addr $user(email) \ - -from_addr [ad_outgoing_sender] \ - -subject $subject \ - -body $body - } { - ns_log Error "Error sending out password changed notification to account owner with user_id $user(user_id), email $user(email): $errmsg\n$::errorInfo" + -send_immediately \ + -to_addr $user(email) \ + -from_addr [ad_outgoing_sender] \ + -subject $subject \ + -body $body + } on error {errorMsg} { + ad_log Error "Error sending out password changed notification to account owner with user_id $user(user_id), email $user(email): $errorMsg" } } @@ -509,7 +511,7 @@ -package_id [ad_conn subsite_id] -default 0] || $email_reg_confirm_p } { - with_catch errmsg { + ad_try { auth::password::email_password \ -username $username \ -authority_id $authority_id \ @@ -520,17 +522,17 @@ -default [ad_system_owner]] \ -subject_msg_key "acs-subsite.email_subject_Registration_password" \ -body_msg_key "acs-subsite.email_body_Registration_password" - } { + } on error {errorMsg} { # We don't fail hard here, just log an error - ns_log Error "Error sending registration confirmation to $email.\n$::errorInfo" + ad_log Error "Error sending registration confirmation to $email: $errorMsg" } } } # LARS TODO: Move this out of the local driver and into the auth framework # Notify admin on new registration if { [parameter::get -parameter NotifyAdminOfNewRegistrationsP -default 0] } { - with_catch errmsg { + ad_try { set admin_email [parameter::get \ -parameter NewRegistrationEmailAddress \ -package_id [ad_conn subsite_id] \ @@ -550,9 +552,9 @@ -from_addr [ad_outgoing_sender] \ -subject [lang::message::lookup $admin_locale acs-subsite.lt_New_registration_at_s] \ -body [lang::message::lookup $admin_locale acs-subsite.lt_first_names_last_name] - } { + } on error {errorMsg} { # We don't fail hard here, just log an error - ns_log Error "Error sending admin notification to $admin_email.\n$::errorInfo" + ad_log Error "Error sending admin notification to $admin_email: $errorMsg" } } Index: openacs-4/packages/acs-authentication/tcl/password-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/password-procs.tcl,v diff -u -N -r1.20 -r1.21 --- openacs-4/packages/acs-authentication/tcl/password-procs.tcl 7 Aug 2017 23:47:46 -0000 1.20 +++ openacs-4/packages/acs-authentication/tcl/password-procs.tcl 29 Dec 2017 10:46:39 -0000 1.21 @@ -61,10 +61,10 @@ set authority_id [acs_user::get_element -user_id $user_id -element authority_id] set result_p 0 - with_catch errmsg { + ad_try { set result_p [auth::password::CanChangePassword -authority_id $authority_id] - } { - ns_log Error "Error invoking CanChangePassword operation for authority_id $authority_id:\n$::errorInfo" + } on error {errorMsg} { + ad_log Error "Error invoking CanChangePassword operation for authority_id $authority_id" } return $result_p } @@ -77,11 +77,8 @@ Change the user's password. @param user_id The ID of the user whose password you want to change. - @param old_password The current password of that user. This is required for security purposes. - @param new_password The desired new password of the user. - @return An array list with the following entries: } { - with_catch errmsg { + ad_try { array set result [auth::password::RetrievePassword \ -authority_id $authority_id \ -username $username] # We do this so that if there aren't even a password_status in the array, that gets caught below set dummy $result(password_status) - } { + } on error {errorMsg} { set result(password_status) failed_to_connect set result(password_message) "Error invoking the password management driver." - ns_log Error "Error invoking password management driver for authority_id = $authority_id: $::errorInfo" + ad_log Error "Error invoking password management driver for authority_id = $authority_id: $errorMsg" } # Check the result code and provide canned responses switch $result(password_status) { ok { if { [info exists result(password)] && $result(password) ne "" } { # We have retrieved or reset a forgotten password that we should email to the user - with_catch errmsg { + ad_try { auth::password::email_password \ -authority_id $authority_id \ -username $username \ -password $result(password) \ -subject_msg_key "acs-subsite.email_subject_Forgotten_password" \ -body_msg_key "acs-subsite.email_body_Forgotten_password" - } { + } on error {errorMsg} { # We could not inform the user of his email - we failed set result(password_status) "failed_to_connect" set result(password_message) [_ acs-subsite.Error_sending_mail] - ns_log Error "We had an error sending out email with new password to username $username, authority $authority_id:\n$::errorInfo" + ad_log Error "We had an error sending out email with new password to username $username, authority $authority_id: $errorMsg" } } if { ![info exists result(password_message)] || $result(password_message) eq "" } { @@ -390,11 +387,11 @@ @return 1 if the authority allows resetting passwords, 0 otherwise. } { set result_p 0 - with_catch errmsg { + ad_try { set result_p [auth::password::CanResetPassword \ - -authority_id $authority_id] - } { - ns_log Error "Error invoking CanResetPassword operation for authority_id $authority_id:\n$::errorInfo" + -authority_id $authority_id] + } on error {errorMsg} { + ad_log Error "Error invoking CanResetPassword operation for authority_id $authority_id: $errorMsg" } return $result_p } @@ -433,17 +430,17 @@ } { - with_catch errmsg { + ad_try { array set result [auth::password::ResetPassword \ -authority_id $authority_id \ -username $username] # We do this so that if there aren't even a password_status in the array, that gets caught below set dummy $result(password_status) - } { + } on error {errorMsg} { set result(password_status) failed_to_connect set result(password_message) "Error invoking the password management driver." - ns_log Error "Error invoking password management driver for authority_id = $authority_id: $::errorInfo" + ad_log Error "Error invoking password management driver for authority_id = $authority_id: $errorMsg" } # Check the result code and provide canned responses @@ -456,26 +453,26 @@ -default 1]) } { # We have retrieved or reset a forgotten password that we should email to the user - with_catch errmsg { + ad_try { auth::password::email_password \ -authority_id $authority_id \ -username $username \ -password $result(password) \ -subject_msg_key "acs-subsite.email_subject_Forgotten_password" \ -body_msg_key "acs-subsite.email_body_Forgotten_password" - } { + } on error {errorMsg} { # We could not inform the user of his email - we failed set result(password_status) "failed_to_connect" set result(password_message) [_ acs-subsite.Error_sending_mail] - ns_log Error "We had an error sending out email with new password to username $username, authority $authority_id:\n$::errorInfo" + ad_log Error "We had an error sending out email with new password to username $username, authority $authority_id: $errorMsg" } } if { ![info exists result(password_message)] || $result(password_message) eq "" } { set result(password_message) [_ acs-subsite.Check_Your_Inbox] } } no_account - not_supported - retrieve_error - failed_to_connect { - if { (![info exists result(password_message)] || $result(password_message) eq "") } { + if { ![info exists result(password_message)] || $result(password_message) eq "" } { array set default_message { no_account {Unknown username} not_supported {This operation is not supported} Index: openacs-4/packages/acs-authentication/tcl/sync-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/sync-procs.tcl,v diff -u -N -r1.37 -r1.38 --- openacs-4/packages/acs-authentication/tcl/sync-procs.tcl 29 Dec 2017 10:07:43 -0000 1.37 +++ openacs-4/packages/acs-authentication/tcl/sync-procs.tcl 29 Dec 2017 10:46:39 -0000 1.38 @@ -178,7 +178,7 @@ if { ![template::util::is_true $job(interactive_p)] && $email_p } { # Only send out email if not an interactive job - with_catch errmsg { + ad_try { acs_mail_lite::send -send_immediately \ -to_addr [ad_system_owner] \ -from_addr [ad_system_owner] \ @@ -192,9 +192,9 @@ Job message : $job(message) To view the complete log, please visit\n$job(log_url)" - } { + } on error {errorMsg} { # We don't fail hard here, just log an error - ns_log Error "Error sending registration confirmation to [ad_system_owner].\n$::errorInfo" + ad_log Error "Error sending registration confirmation to [ad_system_owner]: $errorMsg" } } @@ -367,7 +367,7 @@ # Only actually perform the action if we didn't already encounter a problem if { $success_p } { - with_catch errmsg { + ad_try { switch $operation { "insert" { # We set email_verified_p to 't', because we trust the email we get from the remote system @@ -452,9 +452,9 @@ } } } - } { + } on error {errorMsg} { # Get errorInfo and log it - ns_log Error "Error during batch syncrhonization job:\n$::errorInfo" + ad_log Error "Error during batch syncrhonization job: $errorMsg" set success_p 0 set result(message) $::errorInfo } @@ -541,9 +541,11 @@ } set elms [list] - with_catch errmsg { + ad_try { set elms [auth::sync::GetElements -authority_id $authority_id] - } {} + } on error {errorMsg} { + ad_log error "auth::sync::GetElements raised: $errorMsg" + } return $elms }