Skip to content

Commit

Permalink
Fix bug where app crashes when any error code is returned from compet…
Browse files Browse the repository at this point in the history
…ition creation tba edge function
  • Loading branch information
alaninnovates committed Oct 25, 2024
1 parent d10c536 commit a088f29
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/src/components/modals/AddCompetitionModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import StandardModal from './StandardModal';
import {supabase} from '../../lib/supabase';
import SelectMenu from '../form/SelectMenu';
import {getLighterColor} from '../../lib/ColorReadability';
import {FunctionsHttpError} from '@supabase/supabase-js';

function Spacer() {
return <View style={{height: '2%'}} />;
Expand Down Expand Up @@ -71,7 +72,15 @@ function AddCompetitionModal({visible, setVisible, onRefresh}) {
},
);
if (fetchTbaEventError) {
Alert.alert('Error', await fetchTbaEventError.context.json());
if (fetchTbaEventError instanceof FunctionsHttpError) {
const errorMessage = await fetchTbaEventError.context.json();
Alert.alert('Error', errorMessage.message);
} else {
Alert.alert(
'Error',
'An unknown error has occurred. Try again or contact support.',
);
}
return false;
}
const {data: eventData, error: eventError} = await supabase
Expand Down

0 comments on commit a088f29

Please sign in to comment.