Skip to content

Commit 1bb2312

Browse files
committed
feat: improve auth error message
1 parent 5687e90 commit 1bb2312

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/mod.ts

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ await cmd.parse(Deno.args).catch((err) => {
4444
Deno.exit(err.exitCode);
4545
} else {
4646
console.error(`Error: ${err.message}`);
47-
console.error(err);
4847

4948
Deno.exit(1);
5049
}

src/util/auth.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { base64, cliffy } from "../deps.ts";
1+
import { base64 } from "../deps.ts";
22
import { loadConfig } from "../config.ts";
33
/**
44
* Parse cli config and return a basic auth header string
@@ -20,12 +20,12 @@ export async function parseAuth(options: {
2020
apiKey = config.apiKey;
2121
}
2222

23-
if (!email) {
24-
throw new cliffy.ValidationError("email");
25-
}
26-
if (!apiKey) {
27-
throw new cliffy.ValidationError("apiKey");
23+
if (!email || !apiKey) {
24+
throw new Error(
25+
`Not authenticated, please run "upstash auth login" or specify your config file with "--config=/path/to/.upstash.json"`,
26+
);
2827
}
28+
2929
return await Promise.resolve(
3030
`Basic ${base64.encode([email, apiKey].join(":"))}`,
3131
);

0 commit comments

Comments
 (0)