Skip to content

Commit

Permalink
fix: dont log golbat 404 pokemon id errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Feb 8, 2024
1 parent b6c0fae commit 7292d13
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 6 additions & 6 deletions server/src/graphql/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ const resolvers = {
category,
status,
)
if (category === 'pokemon') {
if (category === 'pokemon' && result.pokemon) {
result.pokemon = result.pokemon.map((x) => ({
...x,
allForms: !x.form,
Expand All @@ -506,13 +506,13 @@ const resolvers = {
xl: x.min_weight !== 0,
}))
}
if (category === 'invasion') {
if (category === 'invasion' && result.invasion) {
result.invasion = result.invasion.map((x) => ({
...x,
real_grunt_id: PoracleAPI.getRealGruntId(x, Event.invasions),
}))
}
if (category === 'raid') {
if (category === 'raid' && result.raid) {
result.raid = result.raid.map((x) => ({
...x,
allMoves: x.move === 9000,
Expand Down Expand Up @@ -656,7 +656,7 @@ const resolvers = {
status,
data,
)
if (category === 'pokemon') {
if (category === 'pokemon' && result.pokemon) {
result.pokemon = result.pokemon.map((x) => ({
...x,
allForms: !x.form,
Expand All @@ -665,13 +665,13 @@ const resolvers = {
xl: x.min_weight !== 0,
}))
}
if (category === 'invasion') {
if (category === 'invasion' && result.invasion) {
result.invasion = result.invasion.map((x) => ({
...x,
real_grunt_id: PoracleAPI.getRealGruntId(x, Event.invasions),
}))
}
if (category === 'raid') {
if (category === 'raid' && result.raid) {
result.raid = result.raid.map((x) => ({
...x,
allMoves: x.move === 9000,
Expand Down
8 changes: 7 additions & 1 deletion server/src/services/api/fetchJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const fs = require('fs')
const { resolve } = require('path')

const { default: fetch } = require('node-fetch')
const { default: fetch, Response } = require('node-fetch')

const config = require('@rm/config')
const { log, HELPERS } = require('@rm/logger')
Expand Down Expand Up @@ -31,6 +31,12 @@ async function fetchJson(url, options = undefined) {
return response.json()
} catch (e) {
if (e instanceof Error) {
if (
e.cause instanceof Response &&
e.cause.status === 404 &&
url.includes('/api/pokemon/id')
)
return e.cause
log.error(HELPERS.fetch, `Unable to fetch ${url}`, '\n', e)
if (options) {
fs.writeFileSync(
Expand Down

0 comments on commit 7292d13

Please sign in to comment.