Skip to content

Commit

Permalink
Implement FTPConnectionFailed exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Aug 20, 2011
1 parent a84bc07 commit ed3dfef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions application/MantisBT/Exception/Attachment/FTPConnectionFailed.php
@@ -0,0 +1,13 @@
<?php
namespace MantisBT\Exception\Attachment;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class FTPConnectionFailed extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_FTP_CONNECT_ERROR, null, false);
parent::__construct(ERROR_FTP_CONNECT_ERROR, $errorMessage, null);
$this->responseCode = 500;
}
}
3 changes: 2 additions & 1 deletion application/core/file_api.php
Expand Up @@ -42,6 +42,7 @@
use MantisBT\Exception\Attachment\AttachmentOversized;
use MantisBT\Exception\Attachment\AttachmentsPathInvalid;
use MantisBT\Exception\Attachment\EmptyAttachment;
use MantisBT\Exception\Attachment\FTPConnectionFailed;

require_api( 'access_api.php' );
require_api( 'authentication_api.php' );
Expand Down Expand Up @@ -434,7 +435,7 @@ function file_ftp_connect() {
$login_result = ftp_login( $conn_id, config_get( 'file_upload_ftp_user' ), config_get( 'file_upload_ftp_pass' ) );

if(( !$conn_id ) || ( !$login_result ) ) {
trigger_error( ERROR_FTP_CONNECT_ERROR, ERROR );
throw new FTPConnectionFailed();
}

return $conn_id;
Expand Down

0 comments on commit ed3dfef

Please sign in to comment.