Skip to content

Commit

Permalink
fix(core): fix error handling in network (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lipraty authored Nov 5, 2023
1 parent 22231d2 commit 2a1f402
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ class ImageService extends Service {
const tags = source.tokenize(query.query)
const images = await source.get({ count: query.count, tags, raw: query.query }).catch((err) => {
if (Quester.isAxiosError(err)) {
logger.warn(`source ${source.config.label} request failed with code ${err.status} ${JSON.stringify(err.response?.data)}`)
logger.warn(`source ${source.config.label} request failed ${err.status ? `with code ${err.status} ${JSON.stringify(err.response?.data)}` : ''}`)
} else {
logger.error(`source ${source.config.label} unknown error: ${err.message}`)
}
// log full error in debug mode, if user want to see it.
logger.debug(err)
return []
})
if (images?.length) return Object.assign(images, {
Expand Down

0 comments on commit 2a1f402

Please sign in to comment.