Overview

Namespaces

  • Larislackers
    • BinanceApi
      • Enums
      • Exception

Classes

  • Larislackers\BinanceApi\BinanceApiContainer
  • Larislackers\BinanceApi\Enums\BasicEnum
  • Larislackers\BinanceApi\Enums\BinanceApi
  • Larislackers\BinanceApi\Enums\ConnectionDetails

Exceptions

  • Larislackers\BinanceApi\Exception\BinanceApiException
  • Larislackers\BinanceApi\Exception\LarislackersException
  • Overview
  • Namespace
  • Class
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 
<?php

namespace Larislackers\BinanceApi\Exception;

/**
 * Class BinanceApiException
 *
 * @package \Larislackers\BinanceApi\Exception
 */
class BinanceApiException extends \Exception
{
    /**
     * Error code.
     *
     * @var int
     */
    protected $code;

    /**
     * Error message.
     *
     * @var string
     */
    protected $message;

    /**
     * BinanceApiException constructor.
     *
     * @param string          $message  The exception message.
     * @param int             $code     The exception code.
     * @param \Exception|null $previous The previous exceptions.
     */
    public function __construct($message, $code = 0, \Exception $previous = null)
    {
        $this->_decodeBinanceException($message);
        parent::__construct($this->message, $this->code, $previous);
    }

    /**
     * String representation of the exception.
     *
     * @return string
     */
    public function __toString()
    {
        return __CLASS__ . ': [' . $this->code . ']: ' . $this->message;
    }

    /**
     * Decodes received exception message.
     *
     * @param string $message The exception message.
     */
    private function _decodeBinanceException($message)
    {
        $msg = json_decode($message, true);
        $this->code = isset($msg['code']) ? $msg['code'] : 0;
        $this->message = isset($msg['msg']) ? $msg['msg'] : '';
    }
}
API documentation generated by ApiGen