Skip to content

Commit

Permalink
better error
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Jan 11, 2024
1 parent e6f1d59 commit 733b724
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const initDebugger = debugFactory('graph-cli:commands:init');
const AVAILABLE_NETWORKS = async () => {
const logger = initDebugger.extend('AVAILABLE_NETWORKS');
try {
logger('fetching chain_list from studio')
logger('fetching chain_list from studio');
const res = await fetch(SUBGRAPH_STUDIO_URL, {
method: 'POST',
headers: {
Expand Down Expand Up @@ -633,6 +633,14 @@ async function processInitForm(
const choices = (await AVAILABLE_NETWORKS())?.[
product === 'subgraph-studio' ? 'studio' : 'hostedService'
];

if (!choices) {
this.error(
'Unable to fetch available networks from API. Please report this issue. As a workaround you can pass `--network` flag from the available networks: https://thegraph.com/docs/en/developing/supported-networks',
{ exit: 1 },
);
}

const { network } = await prompt.ask<{ network: string }>([
{
type: 'select',
Expand Down

0 comments on commit 733b724

Please sign in to comment.