Improve error message

This commit is contained in:
Ian Philips 2022-05-06 16:32:03 -04:00
parent 7fe599c8f9
commit b3d204b128
2 changed files with 8 additions and 4 deletions

View File

@ -72,10 +72,12 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall(
console.log('user current invested amount', currentInvested) console.log('user current invested amount', currentInvested)
console.log('mana limit:', manaLimitPerUser) console.log('mana limit:', manaLimitPerUser)
if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser) if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser) {
const manaAllowed = manaLimitPerUser - currentInvested
return { return {
status: 'error', status: 'error',
message: `Market investment limit is M$${manaLimitPerUser}, you've M$${currentInvested} already`, message: `Market bet cap is M$${manaLimitPerUser}, M$${manaAllowed} left`,
}
} }
const [lastAnswer] = await getValues<Answer>( const [lastAnswer] = await getValues<Answer>(
firestore firestore

View File

@ -82,10 +82,12 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
console.log('user current invested amount', currentInvested) console.log('user current invested amount', currentInvested)
console.log('mana limit:', manaLimitPerUser) console.log('mana limit:', manaLimitPerUser)
if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser) if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser) {
const manaAllowed = manaLimitPerUser - currentInvested
return { return {
status: 'error', status: 'error',
message: `Market investment limit is M$${manaLimitPerUser}, you've M$${currentInvested} already`, message: `Market bet cap is M$${manaLimitPerUser}, M$${manaAllowed} left`,
}
} }
} }