Skip to content

Commit

Permalink
tavern: Improve error handling of patreon accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
bekriebel committed May 1, 2024
1 parent d966499 commit aba681b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"LIVEKITAVCLIENT.tavernAccountMissing": "LiveKit connection information missing; please sign in to your Patreon account with access to the Tavern LiveKit cluster",
"LIVEKITAVCLIENT.patreonAccountNote": "Patreon account",
"LIVEKITAVCLIENT.patreonAccountNotMember": "Not a member",
"LIVEKITAVCLIENT.patreonAccountError": "Error getting account; please sign out and try again",
"LIVEKITAVCLIENT.TooltipEnableUserVideo": "Enable User Video",
"LIVEKITAVCLIENT.TooltipDisableUserVideo": "Disable User Video",
"LIVEKITAVCLIENT.TooltipEnableUserAudio": "Enable User Audio",
Expand Down
7 changes: 3 additions & 4 deletions src/LiveKitAVConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,16 @@ export default class LiveKitAVConfig extends AVConfig {
log.warn("Error validating Patreon account", e);
return;
}
if (!response.ok) {
log.warn("Error validating Patreon account", response);
return;
}
let responseJson;
try {
responseJson = await response.json();
} catch (e) {
log.warn("Error parsing response", e);
return;
}
if (!response.ok) {
log.error("Error validating Patreon account", responseJson);
}
return responseJson;
}

Expand Down
4 changes: 2 additions & 2 deletions src/LiveKitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@ export default class LiveKitClient {
}),
});
} catch (e) {
log.warn("Error validating Patreon account", e);
log.error("Error validating Patreon account", e);
return "";
}
if (!response.ok) {
log.warn("Error validating Patreon account", response);
log.error("Error validating Patreon account", await response.json());
return "";
}
let responseText;
Expand Down
8 changes: 6 additions & 2 deletions templates/av-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@
</button>
{{#if tavernAuthResponse }}
<p class="notes">
{{ localize "LIVEKITAVCLIENT.patreonAccountNote"}}: <i>{{#if tavernAuthResponse.vanity}}{{tavernAuthResponse.vanity}}{{else}}{{tavernAuthResponse.full_name}}{{/if}}</i>
(<a href="https://www.patreon.com/bekit">{{#if tavernAuthResponse.active_tier}}{{tavernAuthResponse.active_tier}}{{else}}{{localize "LIVEKITAVCLIENT.patreonAccountNotMember"}}{{/if}}</a>)
{{#if tavernAuthResponse.error}}
{{ localize "LIVEKITAVCLIENT.patreonAccountError"}}: <i>{{tavernAuthResponse.error}}</i>
{{else}}
{{ localize "LIVEKITAVCLIENT.patreonAccountNote"}}: <i>{{#if tavernAuthResponse.vanity}}{{tavernAuthResponse.vanity}}{{else}}{{tavernAuthResponse.full_name}}{{/if}}</i>
(<a href="https://www.patreon.com/bekit">{{#if tavernAuthResponse.active_tier}}{{tavernAuthResponse.active_tier}}{{else}}{{localize "LIVEKITAVCLIENT.patreonAccountNotMember"}}{{/if}}</a>)
{{/if}}
</p>
{{/if}}
{{else}}
Expand Down

0 comments on commit aba681b

Please sign in to comment.