Skip to content

Commit

Permalink
fix: improve exception messages for required actions (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
khskekec committed Sep 27, 2024
1 parent b50811f commit ee2158a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,17 @@ export const LibreLinkUpClient = ({
password,
});

if (loginResponse.data.status === 2)
if (loginResponse.data.status === 2) {
throw new Error(
'Bad credentials. Please ensure that you have entered the credentials of your LibreLinkUp account (and not of your LibreLink account).'
);
}

if (loginResponse.data.status === 4) {
throw new Error(
`Additional action required for your account: ${loginResponse.data.data?.step?.componentName }. Please login via app and perform required steps and try again.`
);
}

if ((loginResponse.data as LoginRedirectResponse).data.redirect) {
const redirectResponse = loginResponse.data as LoginRedirectResponse;
Expand Down Expand Up @@ -158,6 +165,10 @@ export const LibreLinkUpClient = ({
if (!connectionId) {
const connections = await getConnections();

if (connections.data.length === 0) {
throw new Error('Your account does not follow any patients. Pleas start following and try again.')
}

connectionId = getConnection(connections.data);
}

Expand Down

0 comments on commit ee2158a

Please sign in to comment.