Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a better error message when an unknown error occurs in deployment #304

Merged
merged 3 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zkapp-cli",
"version": "0.4.19",
"version": "0.4.20",
"description": "CLI to create a zkApp (\"zero-knowledge app\") for Mina Protocol.",
"keywords": [
"cli",
Expand Down
9 changes: 7 additions & 2 deletions src/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { table, getBorderCharacters } = require('table');
const glob = require('fast-glob');
const { step } = require('./helpers');
const fetch = require('node-fetch');
const util = require('util');

const { red, green, bold, reset } = require('chalk');
const log = console.log;
Expand Down Expand Up @@ -419,7 +420,7 @@ async function deploy({ alias, yes }) {

if (!txn || txn?.kind === 'error') {
// Note that the thrown error object is already console logged via step().
log(red(getErrorMessage(txn.message ?? [])));
log(red(getErrorMessage(txn)));
await shutdown();
return;
}
Expand Down Expand Up @@ -563,7 +564,11 @@ function getAccountQuery(publicKey) {
}`;
}

function getErrorMessage(errors) {
function getErrorMessage(error) {
let errors = error?.message ?? [];
if (errors.length === 0) {
return `Failed to send transaction. Unknown error: ${util.format(error)}`;
}
let errorMessage =
' Failed to send transaction to relayer. Errors: ' +
errors.map((e) => e.message);
Expand Down