Skip to content

Commit

Permalink
nicer message when unable to call v4
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilde345 committed Jul 3, 2024
1 parent f84d1d1 commit 58f11da
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/fauna-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ class FaunaCommand extends Command {
}
}

mapConnectionError({ err, connectionOptions }) {
mapConnectionError({ err, connectionOptions, version }) {
if (err instanceof errors.Unauthorized) {
this.error(
`Could not Connect to ${connectionOptions.url} Unauthorized Secret`
);
}
if (err instanceof errors.PermissionDenied && version === "v4") {
this.error(
`This account is not allowed to query Fauna v4. Please use the v10 endpoint.`
);
}
this.error(err);
}

Expand Down Expand Up @@ -153,7 +158,7 @@ class FaunaCommand extends Command {
logConnectionMessage(connectionOptions);
return this.clients[hashKey];
} catch (err) {
this.mapConnectionError({ err, connectionOptions });
this.mapConnectionError({ err, connectionOptions, version });
}
} else {
// construct v10 client
Expand Down

0 comments on commit 58f11da

Please sign in to comment.