Skip to content

Commit

Permalink
improved post/get error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
underwhelmingToaster committed Sep 1, 2021
1 parent cec090e commit e637a92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/api/suggestionManager.dart
Expand Up @@ -27,7 +27,7 @@ class SuggestionManager{

return suggestions;
}else{
throw Exception('Failed to load suggestions');
throw Exception('Failed to load all suggestions. Status: ' + response.statusCode.toString());
}
}

Expand All @@ -36,12 +36,17 @@ class SuggestionManager{
if(response.statusCode == 200){
return Suggestion.fromJson(jsonDecode(response.body));
}else{
throw Exception('Failed to load suggestion');
throw Exception('Failed to load single suggestion. Status: ' + response.statusCode.toString());
}
}

static void postSuggestion(Suggestion suggestion){
http.post(Uri.parse('/api/suggestion/add/'), body: suggestion);
static Future<void> postSuggestion(Suggestion suggestion) async {
final response = await http.post(Uri.parse('/api/suggestion/add/'), body: suggestion);
if(response.statusCode == 200){
return;
}else{
throw Exception('Failed to post new Suggestion. Status: ' + response.statusCode.toString());
}
}

static Future<List<Marker>> formatSuggestions() async{
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Expand Up @@ -69,7 +69,7 @@ class _MapFragment extends State<StatefulMapFragment> {
icon: const Icon(Icons.menu),
tooltip: 'Show Snackbar',
onPressed: () {
// TODO snackbar
// TODO menu
},
),
]
Expand Down

0 comments on commit e637a92

Please sign in to comment.