Skip to content

Commit d35125f

Browse files
committed
Restore login error handling
Avoids Cannot read property 'success' of undefined error
1 parent 8edb30e commit d35125f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

app/exec/login.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,22 @@ export class Login extends TfCommand<CoreArguments, LoginResult> {
4141
await tfxCredStore.storeCredential(collectionUrl, "allusers", credString);
4242
await tfxCache.setItem("cache", "connection", collectionUrl);
4343
return { success: true } as LoginResult;
44-
} catch (err) {}
44+
} catch (err) {
45+
if (err && err.statusCode && err.statusCode === 401) {
46+
trace.debug("Connection failed: invalid credentials.");
47+
throw new Error("Invalid credentials. " + err.message);
48+
} else if (err) {
49+
trace.debug("Connection failed.");
50+
throw new Error(
51+
"Connection failed. Check your internet connection & collection URL." +
52+
os.EOL +
53+
"Message: " +
54+
err.message,
55+
);
56+
} else {
57+
throw new Error("Unknown error logging in.");
58+
}
59+
}
4560
});
4661
}
4762

0 commit comments

Comments
 (0)