mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
chore: more descriptive logging
This commit is contained in:
@@ -285,7 +285,7 @@ export const makeSocket = ({
|
||||
const message = STATUS_CODES[responseStatusCode] || 'unknown'
|
||||
throw new Boom(
|
||||
`Unexpected status in '${Array.isArray(json) ? json[0] : (json?.tag || 'query')}': ${message}(${responseStatusCode})`,
|
||||
{ data: { query: json, message }, statusCode: response.status }
|
||||
{ data: { query: json, response }, statusCode: response.status }
|
||||
)
|
||||
}
|
||||
return response
|
||||
|
||||
@@ -471,9 +471,9 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: C
|
||||
for (let hostname of hosts) {
|
||||
const auth = encodeURIComponent(uploadInfo.auth) // the auth token
|
||||
const url = `https://${hostname}${MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`
|
||||
|
||||
let result: any
|
||||
try {
|
||||
const {data: result} = await axios.post(
|
||||
const body = await axios.post(
|
||||
url,
|
||||
stream,
|
||||
{
|
||||
@@ -488,6 +488,7 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: C
|
||||
maxContentLength: Infinity,
|
||||
}
|
||||
)
|
||||
result = body.data
|
||||
|
||||
if(result?.url || result?.directPath) {
|
||||
urls = {
|
||||
@@ -501,7 +502,7 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: C
|
||||
}
|
||||
} catch (error) {
|
||||
const isLast = hostname === hosts[uploadInfo.hosts.length-1]
|
||||
logger.debug({ trace: error.stack }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`)
|
||||
logger.debug({ trace: error.stack, uploadResult: result }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`)
|
||||
}
|
||||
}
|
||||
if (!urls) {
|
||||
|
||||
Reference in New Issue
Block a user