Skip to content

Commit bf2134d

Browse files
author
Vítězslav Dvořák
committed
return RuntimeExeptions
1 parent dfd61e3 commit bf2134d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Subreg/Client.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ public function __construct(array $config = [])
8383
}
8484

8585
$this->setObjectName();
86-
$this->login();
86+
87+
if ((\array_key_exists('autologin', $this->config) === false) || $this->config['autologin']) {
88+
$this->login();
89+
}
8790
}
8891

8992
/**
@@ -111,11 +114,11 @@ public static function env2conf(): array
111114
public function logBanner($additions = null)
112115
{
113116
return $this->addStatusMessage(
114-
'API '.str_replace(
117+
'API ' . str_replace(
115118
'://',
116-
'://'.$this->config['login'].'@',
119+
'://' . $this->config['login'] . '@',
117120
$this->config['uri'],
118-
).' php-subreg v'.self::$libVersion.' '.$additions,
121+
) . ' php-subreg v' . self::$libVersion . ' ' . $additions,
119122
'debug',
120123
);
121124
}
@@ -156,7 +159,7 @@ public function call(string $command, array $params = [])
156159
$this->logError($responseRaw['error']);
157160
$this->lastResult = ['error' => $responseRaw['error']];
158161

159-
break;
162+
throw new \RuntimeException($responseRaw['error']['errormsg'], (int) $responseRaw['error']['errorcode']['major']);
160163
}
161164
}
162165

@@ -172,7 +175,7 @@ public function logError(array $errorData): void
172175
{
173176
$this->lastError = $errorData;
174177
$this->addStatusMessage(
175-
$errorData['errorcode']['major'].' '.$errorData['errorcode']['minor'].': '.$errorData['errormsg'],
178+
$errorData['errorcode']['major'] . ' ' . $errorData['errorcode']['minor'] . ': ' . $errorData['errormsg'],
176179
'error',
177180
);
178181
}
@@ -194,7 +197,7 @@ public function login()
194197
if (\array_key_exists('ssid', $loginResponse)) {
195198
$this->token = $loginResponse['ssid'];
196199
$result = true;
197-
$this->setObjectName($params['login'].'@'.$this->getObjectName());
200+
$this->setObjectName($params['login'] . '@' . $this->getObjectName());
198201
}
199202

200203
return $result;

0 commit comments

Comments
 (0)