Skip to content

Commit

Permalink
refactor(cli): improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vplasencia committed Sep 4, 2023
1 parent 6f7dd99 commit d420484
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ program

const groupIds = await getGroupIds(network)

if (groupIds === null) return
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}

const content = `${chalk.bold("Groups")} (${groupIds.length}): \n${groupIds
.map((id: any) => ` - ${id}`)
Expand Down Expand Up @@ -160,7 +163,10 @@ program
if (!groupId) {
const groupIds = await getGroupIds(network)

if (groupIds === null) return
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}

groupId = await getGroupId(groupIds)
}
Expand Down Expand Up @@ -193,6 +199,11 @@ program
}
}

if (!group) {
console.info(`\n ${logSymbols.error}`, "error: the group does not exist\n")
return
}

let content = ` ${chalk.bold("Id")}: ${group.id}\n`
content += ` ${chalk.bold("Admin")}: ${group.admin}\n`
content += ` ${chalk.bold("Merkle tree")}:\n`
Expand Down Expand Up @@ -223,7 +234,10 @@ program
if (!groupId) {
const groupIds = await getGroupIds(network)

if (groupIds === null) return
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}

groupId = await getGroupId(groupIds)
}
Expand Down Expand Up @@ -286,7 +300,10 @@ program
if (!groupId) {
const groupIds = await getGroupIds(network)

if (groupIds === null) return
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}

groupId = await getGroupId(groupIds)
}
Expand Down

0 comments on commit d420484

Please sign in to comment.