mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 09:45:25 +00:00
Refactor RemoteDeleteSpaceService: Simplify success response handling and improve error message formatting
This commit is contained in:
@ -19,8 +19,7 @@ final class RemoteDeleteSpaceService implements DeleteSpaceService {
|
||||
path: await _makeUrl(param),
|
||||
expectedResponseModel: (json) {
|
||||
final response = json as Map<String, dynamic>;
|
||||
final data = response['data'] as Map<String, dynamic>?;
|
||||
final hasSuccessfullyDeletedSpace = data?['success'] as bool? ?? false;
|
||||
final hasSuccessfullyDeletedSpace = response['success'] as bool? ?? false;
|
||||
|
||||
if (!hasSuccessfullyDeletedSpace) {
|
||||
throw APIException('Failed to delete space');
|
||||
@ -33,8 +32,7 @@ final class RemoteDeleteSpaceService implements DeleteSpaceService {
|
||||
final message = e.response?.data as Map<String, dynamic>?;
|
||||
throw APIException(_getErrorMessageFromBody(message));
|
||||
} catch (e) {
|
||||
final formattedErrorMessage = ['Failed to delete space', '$e'].join(': ');
|
||||
throw APIException(formattedErrorMessage);
|
||||
throw APIException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user