Improve error messages

This commit is contained in:
Simon Warta 2020-02-13 23:02:22 +01:00
parent 520f32ed36
commit 62d6bd7bd9
3 changed files with 5 additions and 4 deletions

View File

@ -419,7 +419,7 @@ describe("CosmWasmClient", () => {
const client = CosmWasmClient.makeReadOnly(httpUrl);
await client.queryContractRaw(nonExistentAddress, configKey).then(
() => fail("must not succeed"),
error => expect(error).toMatch(`No contract with address ${nonExistentAddress}`),
error => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`),
);
});
});

View File

@ -430,10 +430,11 @@ describe("RestClient", () => {
expect((myInfo.init_msg as any).beneficiary).toEqual(beneficiaryAddress);
// make sure random addresses don't give useful info
const nonExistentAddress = makeRandomAddress();
await client
.getContractInfo(beneficiaryAddress)
.getContractInfo(nonExistentAddress)
.then(() => fail("this shouldn't succeed"))
.catch(error => expect(error).toMatch(`No contract with address ${beneficiaryAddress}`));
.catch(error => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`));
});
describe("contract state", () => {

View File

@ -311,7 +311,7 @@ export class RestClient {
// rest server returns null if no data for the address
const info: ContractInfo | null = parseWasmResponse(responseData as WasmResponse);
if (!info) {
throw new Error(`No contract with address ${address}`);
throw new Error(`No contract found at address "${address}"`);
}
return info;
}