mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 10:47:25 +01:00
client: Catch exceptions in put methods
This commit is contained in:
parent
9d4554b67f
commit
37a1353297
1 changed files with 55 additions and 35 deletions
|
|
@ -31,6 +31,7 @@ class MusicusClient {
|
|||
///
|
||||
/// Returns true, if the operation was successful.
|
||||
Future<bool> putPerson(Person person) async {
|
||||
try {
|
||||
final response = await _client.put(
|
||||
'$host/persons/${person.id}',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
|
|
@ -38,6 +39,9 @@ class MusicusClient {
|
|||
);
|
||||
|
||||
return response.statusCode == HttpStatus.ok;
|
||||
} on Exception {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a list of all available instruments.
|
||||
|
|
@ -58,6 +62,7 @@ class MusicusClient {
|
|||
///
|
||||
/// Returns true, if the operation was successful.
|
||||
Future<bool> putInstrument(Instrument instrument) async {
|
||||
try {
|
||||
final response = await _client.put(
|
||||
'$host/instruments/${instrument.id}',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
|
|
@ -65,6 +70,9 @@ class MusicusClient {
|
|||
);
|
||||
|
||||
return response.statusCode == HttpStatus.ok;
|
||||
} on Exception {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all works composed by the person with the ID [personId].
|
||||
|
|
@ -92,6 +100,7 @@ class MusicusClient {
|
|||
///
|
||||
/// Returns true, if the operation was successful.
|
||||
Future<bool> putWork(WorkInfo workInfo) async {
|
||||
try {
|
||||
final response = await _client.put(
|
||||
'$host/works/${workInfo.work.id}',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
|
|
@ -99,6 +108,9 @@ class MusicusClient {
|
|||
);
|
||||
|
||||
return response.statusCode == HttpStatus.ok;
|
||||
} on Exception {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a list of all ensembles.
|
||||
|
|
@ -119,6 +131,7 @@ class MusicusClient {
|
|||
///
|
||||
/// Returns true, if the operation was successful.
|
||||
Future<bool> putEnsemble(Ensemble ensemble) async {
|
||||
try {
|
||||
final response = await _client.put(
|
||||
'$host/ensembles/${ensemble.id}',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
|
|
@ -126,6 +139,9 @@ class MusicusClient {
|
|||
);
|
||||
|
||||
return response.statusCode == HttpStatus.ok;
|
||||
} on Exception {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a recording by ID.
|
||||
|
|
@ -139,6 +155,7 @@ class MusicusClient {
|
|||
///
|
||||
/// Returns true, if the operation was successful.
|
||||
Future<bool> putRecording(RecordingInfo recordingInfo) async {
|
||||
try {
|
||||
final response = await _client.put(
|
||||
'$host/recordings/${recordingInfo.recording.id}',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
|
|
@ -146,6 +163,9 @@ class MusicusClient {
|
|||
);
|
||||
|
||||
return response.statusCode == HttpStatus.ok;
|
||||
} on Exception {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Close the internal http client.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue