Skip to content

Commit

Permalink
Error Messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkLightTuna committed Feb 1, 2024
1 parent a5e53a7 commit 6511846
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/foundry_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_root():
conn.request('GET', '/', headers={})
response = conn.getresponse()
if response.status != 200:
raise Exception('csrf_tokens Fack')
raise Exception(response.reason)
csrf_token = response.getheader('Set-Cookie').split('csrftoken=')[1].split(';')[0].strip()
csrf_middleware_token = re.search(r'name="csrfmiddlewaretoken" value="([^"]+)"', response.read().decode()).group(1)
return csrf_token, csrf_middleware_token
Expand Down
4 changes: 2 additions & 2 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"oronder.Configure-Hint": "This will fetch Discord Ids for Users whose Foundry User names match their Discord name. Support for Pomelo Nicknames pending.",
"oronder.Discord-Ids": "Discord Ids",
"oronder.Oronder-Bot-Config": "Oronder Bot Config",
"oronder.Invalid-Auth": "Invalid Server Id and/or Auth Token. Have you run \"/admin init\" in Discord?",
"oronder.Invalid-Auth": "Invalid Auth Token.",
"oronder.Unexpected-Error": "Unexpected Error Occurred!",
"oronder.Could-Not-Be-Found": "could not be found in Discord server.",
"oronder.Discord-Server-Link-Title": "Oronder Discord",
"oronder.Discord-Bot-Link-Title": "Oronder Bot",
"oronder.Auth-Token-Empty": "Auth Token cannot be empty.",
"oronder.Auth-Token-Empty": "No Auth Token. Run \"/admin init\" from your Discord Server to generate a token.",
"oronder.No-Players-To-Sync": "All Players have Discord Ids. Nothing to update.",
"oronder.Skipping-Sync-For": "Skipping sync for",
"oronder.Failed-To-Sync": "failed to sync!",
Expand Down
4 changes: 4 additions & 0 deletions src/module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export function open_socket_with_oronder(update = false) {
auth: {'Authorization': authorization}
})

socket.on('connect_error', (error) => {
Logger.warn(`Oronder Websocket connection failed: ${error.message}`);
})

socket.on('connect', () => {
Logger.info('Oronder Websocket connection established.')
})
Expand Down
8 changes: 3 additions & 5 deletions src/settings-form-application.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ export class OronderSettingsFormApplication extends FormApplication {

async _handle_json_response(response) {
if (!response.ok) {
const errorMessage = await response.text();
const errorDetails = `Status: ${response.status}, Message: ${errorMessage}`

if (response.status === 401) {
throw new Error(game.i18n.localize("oronder.Invalid-Auth") + ". " + errorDetails)
throw new Error(game.i18n.localize("oronder.Invalid-Auth"))
} else {
throw new Error(game.i18n.localize("oronder.Unexpected-Error") + ". " + errorDetails)
const errorMessage = await response.json()
throw new Error(game.i18n.localize("oronder.Unexpected-Error") + ' ' + errorMessage.detail)
}
}

Expand Down

0 comments on commit 6511846

Please sign in to comment.