-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5488d37
commit 373412c
Showing
9 changed files
with
104 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 2 additions & 32 deletions
34
src/ClamavValidator/ClamavValidatorException.php
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,7 @@ | ||
<?php namespace Sunspikes\ClamavValidator; | ||
|
||
use Illuminate\Validation\ValidationException; | ||
use Exception; | ||
|
||
class ClamavValidatorException extends ValidationException | ||
class ClamavValidatorException extends Exception | ||
{ | ||
protected $exception; | ||
|
||
public $attribute; | ||
|
||
public function __construct(\Exception $exception, string $attribute, \Illuminate\Contracts\Validation\Validator $validator, $response = null) | ||
{ | ||
$this->exception = $exception; | ||
$this->attribute = $attribute; | ||
|
||
parent::__construct($validator, $this->makeResponse()); | ||
} | ||
|
||
public function makeResponse() | ||
{ | ||
$message = $this->exception->getMessage(); | ||
|
||
if (substr_count($message, 'SOCKET_ECONNREFUSED')) { | ||
$message = 'Unable to initiate antivirus check. Please try later.'; | ||
} | ||
|
||
if (request()->expectsJson()) { | ||
return response()->json([ | ||
$this->attribute => $message | ||
], 422); | ||
} | ||
|
||
return redirect()->back()->withInput( | ||
request()->input() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.