mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
refactor(client): update error handling to match adonis 5 validators
This commit is contained in:
parent
02360b4e92
commit
210a47f62d
1 changed files with 20 additions and 17 deletions
|
|
@ -115,32 +115,35 @@ export const actions = {
|
||||||
commit('BASIC_REQUEST')
|
commit('BASIC_REQUEST')
|
||||||
try {
|
try {
|
||||||
const resp = await axios(({ url: 'summoner/basic', data: { summoner, region: regionId }, method: 'POST' }))
|
const resp = await axios(({ url: 'summoner/basic', data: { summoner, region: regionId }, method: 'POST' }))
|
||||||
if (resp.data) {
|
if (!resp.data) {
|
||||||
console.log(`---SUMMONER INFOS ${resp.data.account.name}---`)
|
|
||||||
console.log(resp.data)
|
|
||||||
const infos = createBasicSummonerData(resp.data)
|
|
||||||
commit('SUMMONER_FOUND', infos)
|
|
||||||
|
|
||||||
// Add summoner to recent searches
|
|
||||||
dispatch('settings/addRecentSearch', {
|
|
||||||
name: infos.account.name,
|
|
||||||
icon: infos.account.profileIconId,
|
|
||||||
region,
|
|
||||||
}, { root: true })
|
|
||||||
} else {
|
|
||||||
commit('SUMMONER_NOT_FOUND')
|
|
||||||
|
|
||||||
dispatch('notification/add', {
|
dispatch('notification/add', {
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: 'Summoner not found.'
|
message: 'Summoner not found.'
|
||||||
}, { root: true })
|
}, { root: true })
|
||||||
console.log('Summoner not found - store')
|
return commit('SUMMONER_NOT_FOUND')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`---SUMMONER INFOS ${resp.data.account.name}---`)
|
||||||
|
console.log(resp.data)
|
||||||
|
const infos = createBasicSummonerData(resp.data)
|
||||||
|
commit('SUMMONER_FOUND', infos)
|
||||||
|
|
||||||
|
// Add summoner to recent searches
|
||||||
|
dispatch('settings/addRecentSearch', {
|
||||||
|
name: infos.account.name,
|
||||||
|
icon: infos.account.profileIconId,
|
||||||
|
region,
|
||||||
|
}, { root: true })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.response && error.response.status === 422) {
|
||||||
|
dispatch('notification/add', {
|
||||||
|
type: 'error',
|
||||||
|
message: 'Summoner not found.'
|
||||||
|
}, { root: true })
|
||||||
|
}
|
||||||
if (error.message !== 'Summoner changed') {
|
if (error.message !== 'Summoner changed') {
|
||||||
commit('SUMMONER_NOT_FOUND')
|
commit('SUMMONER_NOT_FOUND')
|
||||||
}
|
}
|
||||||
console.log(error)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
championsNotLoaded({ commit }) {
|
championsNotLoaded({ commit }) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue