Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logging): handle media server connection refused error/toast #748

Merged
merged 8 commits into from
May 23, 2024
6 changes: 5 additions & 1 deletion server/api/jellyfin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ class JellyfinAPI {
);
return account.data;
} catch (e) {
throw new Error('Unauthorized');
if (e.code === 'ECONNREFUSED') {
throw new Error('Connection_refused');
} else {
throw new Error('Unauthorized');
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions server/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@
status: 406,
message: 'CREDENTIAL_ERROR_NO_SERVER_TYPE',
});
} else if (e.message === 'Connection_refused') {
logger.error(`Unable to connect to Jellyfin server at ${body.hostname}`, {
Fixed Show fixed Hide fixed
label: 'Auth',
});
return next({
status: 503,
message: 'CONNECTION_REFUSED',
});
} else {
logger.error(e.message, { label: 'Auth' });
return next({
Expand Down
6 changes: 5 additions & 1 deletion src/components/Login/JellyfinLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const messages = defineMessages({
loginerror: 'Something went wrong while trying to sign in.',
adminerror: 'You must use an admin account to sign in.',
credentialerror: 'The username or password is incorrect.',
connectionrefusederror: 'Unable to connect to {mediaServerName} server.',
signingin: 'Signing in…',
signin: 'Sign In',
initialsigningin: 'Connecting…',
Expand Down Expand Up @@ -97,7 +98,10 @@ const JellyfinLogin: React.FC<JellyfinLoginProps> = ({
? messages.credentialerror
: e.message == 'Request failed with status code 403'
? messages.adminerror
: messages.loginerror
: e.message == 'Request failed with status code 503'
? messages.connectionrefusederror
: messages.loginerror,
mediaServerFormatValues
),
{
autoDismiss: true,
Expand Down
Loading