Skip to content

Commit 74527cd

Browse files
committed
fix: 异常信息丢失
1 parent 179e1d8 commit 74527cd

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Lookup/TcpLookupService.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ public function lookup(string $topic): Result
124124

125125
//
126126
default:
127-
throw new RuntimeException($subCommand->getMessage());
127+
throw new RuntimeException(
128+
$subCommand->getMessage() ?: $subCommand->getError()->name(),
129+
$subCommand->getError()->value()
130+
);
128131
}
129132
}
130133

@@ -152,7 +155,10 @@ public function getPartitionedTopicMetadata(string $topic): int
152155
*/
153156
$subCommand = $results->subCommand;
154157
if ($subCommand->getResponse()->value() == CommandPartitionedTopicMetadataResponse\LookupType::Failed_VALUE) {
155-
throw new RuntimeException($subCommand->getMessage());
158+
throw new RuntimeException(
159+
$subCommand->getMessage() ?: $subCommand->getError()->name(),
160+
$subCommand->getError()->value()
161+
);
156162
}
157163

158164
return $subCommand->getPartitions();
@@ -214,4 +220,4 @@ public function close()
214220
{
215221
$this->connection->close();
216222
}
217-
}
223+
}

src/Response.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function checkError()
111111
{
112112
if ($this->subCommand instanceof CommandError) {
113113
throw new RuntimeException(
114-
$this->subCommand->getMessage(),
114+
$this->subCommand->getMessage() ?: $this->subCommand->getError()->name(),
115115
$this->subCommand->getError()->value()
116116
);
117117
}
@@ -128,9 +128,9 @@ protected function checkServerError()
128128
{
129129
if ($this->subCommand instanceof CommandSendError) {
130130
throw new RuntimeException(
131-
$this->subCommand->getMessage(),
131+
$this->subCommand->getMessage() ?: $this->subCommand->getError()->name(),
132132
$this->subCommand->getError()->value()
133133
);
134134
}
135135
}
136-
}
136+
}

0 commit comments

Comments
 (0)