From: Tom Needham Date: Fri, 6 Apr 2012 20:52:41 +0000 (+0000) Subject: Show nice errors X-Git-Tag: v4.0.0beta~385 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2fe0716cb4ba74d338d6af04a8b02fbb8eb1f903;p=nextcloud-server.git Show nice errors --- diff --git a/apps/user_migrate/admin.php b/apps/user_migrate/admin.php index 61b83c2a140..280f7b71969 100644 --- a/apps/user_migrate/admin.php +++ b/apps/user_migrate/admin.php @@ -36,12 +36,18 @@ if (isset($_POST['user_import'])) { $from = $_FILES['owncloud_import']['tmp_name']; $to = get_temp_dir().'/'.$importname.'.zip'; if( !move_uploaded_file( $from, $to ) ){ + $errors[] = array('error'=>'Failed to move the uploaded file','hint'=>'Try checking the permissions of the '.get_temp_dir().' dir.'); OC_Log::write( 'user_migrate', "Failed to copy the uploaded file", OC_Log::ERROR ); - exit(); + $t = new OC_Template( '', 'error', 'user' ); + $t->assign('errors',$errors); + $t->fetchPage(); } if( !$appsstatus = OC_Migrate::import( $to, 'user' ) ){ - die( 'failed to to import' ); + $errors[] = array('error'=>'There was an error while importing the user!','hint'=>'Please check the logs for a more detailed explaination'); + $t = new OC_Template( '', 'error', 'user' ); + $t->assign('errors',$errors); + $t->fetchPage(); } else { // Check import status foreach( $appsstatus as $app => $status ){ @@ -57,10 +63,20 @@ if (isset($_POST['user_import'])) { // Any problems? if( isset( $notsupported ) || isset( $failed ) ){ if( count( $failed ) > 0 ){ - die( 'Some apps failed to import. View the log please.' ); + $errors[] = array('error'=>'Some app data failed to import','hint'=>'App data for: '.implode(', ', $failed).' failed to import.'); + $t = new OC_Template( '', 'error', 'user' ); + $t->assign('errors',$errors); + $t->fetchPage(); } else if( count( $notsupported ) > 0 ){ - die( 'Some apps were not found in this owncloud instance and therefore could not be installed' ); + $errors[] = array('error'=>'Some app data could not be imported, as the apps are not installed on this instance','hint'=>'App data for: '.implode(', ', $notsupported).' failed to import as they were not found. Please install the apps and try again'); + $t = new OC_Template( '', 'error', 'user' ); + $t->assign('errors',$errors); + $t->fetchPage(); } + } else { + // Went swimmingly! + $tmpl = new OC_Template('user_migrate', 'admin'); + return $tmpl->fetchPage(); } }