|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Laratrade\Trader\Concerns; |
|
4
|
|
|
|
|
5
|
|
|
use BadFunctionCallException; |
|
6
|
|
|
|
|
7
|
|
|
trait HandlesErrors |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* The error messages. |
|
11
|
|
|
* |
|
12
|
|
|
* @var array |
|
13
|
|
|
*/ |
|
14
|
|
|
protected static $errors = [ |
|
15
|
|
|
self::ERR_LIB_NOT_INITIALIZE => 'Library not initialized', |
|
16
|
|
|
self::ERR_BAD_PARAM => 'Bad parameter', |
|
17
|
|
|
self::ERR_ALLOC_ERR => 'Allocation error', |
|
18
|
|
|
self::ERR_GROUP_NOT_FOUND => 'Group not found', |
|
19
|
|
|
self::ERR_FUNC_NOT_FOUND => 'Function not found', |
|
20
|
|
|
self::ERR_INVALID_HANDLE => 'Invalid handle', |
|
21
|
|
|
self::ERR_INVALID_PARAM_HOLDER => 'Invalid parameter holder', |
|
22
|
|
|
self::ERR_INVALID_PARAM_HOLDER_TYPE => 'Invalid parameter holder type', |
|
23
|
|
|
self::ERR_INVALID_PARAM_FUNCTION => 'Invalid parameter function', |
|
24
|
|
|
self::ERR_INPUT_NOT_ALL_INITIALIZE => 'Input not all initialized', |
|
25
|
|
|
self::ERR_OUTPUT_NOT_ALL_INITIALIZE => 'Output not all initialized', |
|
26
|
|
|
self::ERR_OUT_OF_RANGE_START_INDEX => 'Out of range on start index', |
|
27
|
|
|
self::ERR_OUT_OF_RANGE_END_INDEX => 'Out of range on end index', |
|
28
|
|
|
self::ERR_INVALID_LIST_TYPE => 'Invalid list type', |
|
29
|
|
|
self::ERR_BAD_OBJECT => 'Bad object', |
|
30
|
|
|
self::ERR_NOT_SUPPORTED => 'Not supported', |
|
31
|
|
|
self::ERR_INTERNAL_ERROR => 'Internal error', |
|
32
|
|
|
self::ERR_UNKNOWN_ERROR => 'Unknown error', |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Handle errors. |
|
37
|
|
|
*/ |
|
38
|
318 |
|
protected function handleErrors() |
|
39
|
|
|
{ |
|
40
|
318 |
|
$errorCode = trader_errno(); |
|
41
|
318 |
|
if (isset(static::$errors[$errorCode])) { |
|
42
|
2 |
|
throw new BadFunctionCallException(static::$errors[$errorCode], $errorCode); |
|
43
|
|
|
} |
|
44
|
316 |
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|