fix cart, fix log cart
This commit is contained in:
@@ -138,7 +138,15 @@ class ProductsRemoteDataSource {
|
||||
throw Exception('Product not found: $itemCode');
|
||||
}
|
||||
|
||||
return ProductModel.fromJson(message as Map<String, dynamic>);
|
||||
// Handle API error response: {success: false, message: "Item not found"}
|
||||
if (message is Map<String, dynamic>) {
|
||||
if (message['success'] == false) {
|
||||
throw Exception(message['message'] ?? 'Product not found: $itemCode');
|
||||
}
|
||||
return ProductModel.fromJson(message);
|
||||
}
|
||||
|
||||
throw Exception('Invalid response format for product: $itemCode');
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 404) {
|
||||
throw Exception('Product not found: $itemCode');
|
||||
|
||||
Reference in New Issue
Block a user