Skip to content

Commit 3f6a14b

Browse files
fix error messages on publish
1 parent 1e756a0 commit 3f6a14b

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/cli/domain/registry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli {
106106
try {
107107
await put(options.route, options.path, requestsHeaders);
108108
} catch (err) {
109-
let parsedError = err as any as { code?: string; error?: string };
109+
let parsedError = (err as any).response.body || (err as any);
110110
let errMsg = '';
111-
if (!_.isObject(err)) {
111+
if (!_.isObject(parsedError)) {
112112
try {
113-
parsedError = JSON.parse(String(err));
113+
parsedError = JSON.parse(String(parsedError));
114114
} catch (er) {}
115115
}
116116

src/cli/facade/publish.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ const publish = ({
8989
await registry.putComponent(options);
9090
logger.ok(strings.messages.cli.PUBLISHED(options.route));
9191
} catch (err: any) {
92-
if (
93-
err === 'Unauthorized' ||
94-
err.message === 'Unauthorized' ||
95-
err.response?.body === 'Unauthorized'
96-
) {
92+
if (err === 'Unauthorized' || err.message === 'Unauthorized') {
9793
if (!!options.username || !!options.password) {
9894
logger.err(
9995
strings.errors.cli.PUBLISHING_FAIL(

0 commit comments

Comments
 (0)