Skip to content

Commit 5510b6f

Browse files
committed
Move assert code.
1 parent b1d9cea commit 5510b6f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/KmsClient.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ export class KmsClient {
692692
capability = `${ZCAP_ROOT_PREFIX}${encodeURIComponent(url)}`;
693693
}
694694

695+
let result;
695696
try {
696697
const headers = await signCapabilityInvocation({
697698
url, method: 'post', headers: DEFAULT_HEADERS, json: config,
@@ -700,19 +701,19 @@ export class KmsClient {
700701

701702
const agent = httpsAgent || this.agent;
702703
// send request
703-
const result = await httpClient.post(url, {
704+
result = await httpClient.post(url, {
704705
agent, headers, json: config
705706
});
706-
707-
_assert(result.data, 'result.data', 'object');
708-
_assert(result.data.id, 'result.data.id', 'string');
709-
return result.data;
710707
} catch(e) {
711708
_handleClientError({
712709
message: 'Error during "create keystore" operation.',
713710
cause: e
714711
});
715712
}
713+
714+
_assert(result.data, 'result.data', 'object');
715+
_assert(result.data.id, 'result.data.id', 'string');
716+
return result.data;
716717
}
717718

718719
async _getUncachedKeyDescription({url, capability, invocationSigner}) {

0 commit comments

Comments
 (0)