Skip to content

Commit

Permalink
add error handling for synology requests
Browse files Browse the repository at this point in the history
  • Loading branch information
rush42 committed Nov 18, 2024
1 parent c99397a commit 07fe869
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions processing/utils/synology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ async function logToSynology(message: string, token: string) {
}
const url = params.synologyURL + token
const payload = { text: `#${params.environment}: ${message}` }
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
})

try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
})

if (response.status !== 200) {
throw new Error(`Error logging to Synology: ${response.statusText}`)
}
} catch (error) {
console.error(`Error logging to Synology`)
}
}

/**
Expand Down

0 comments on commit 07fe869

Please sign in to comment.