fix: mejorar manejo de errores en funciones de servicio y respuesta de API
This commit is contained in:
@@ -5,8 +5,8 @@ export const calculateValueFunction = async (payload) => {
|
||||
const response = await api.post('/criteria/doc/value-function', payload);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error calculating value function:', error);
|
||||
throw error.response?.data?.detail || error.message;
|
||||
if (error.response && error.response.data) throw error.response.data;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,8 +15,8 @@ export const buildFuzzyGraph = async (payload) => {
|
||||
const response = await api.post('/criteria/doc-it2mf/build', payload);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error building fuzzy graph:', error);
|
||||
throw error.response?.data?.detail || error.message;
|
||||
if (error.response && error.response.data) throw error.response.data;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,8 +25,8 @@ export const saveToHistory = async (payload) => {
|
||||
const response = await api.post('/history/add', payload);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error saving to history:', error);
|
||||
throw error.response?.data?.detail || error.message;
|
||||
if (error.response && error.response.data) throw error.response.data;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,17 +35,17 @@ export const getUserHistory = async () => {
|
||||
const response = await api.get('/history/user');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching history:', error);
|
||||
throw error.response?.data?.detail || error.message;
|
||||
if (error.response && error.response.data) throw error.response.data;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteHistoryItem = async (id) => {
|
||||
try {
|
||||
const response = await api.delete(`/history/delete/${id}`);
|
||||
const response = await api.delete(`/history/${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error deleting history item:', error);
|
||||
throw error.response?.data?.detail || error.message;
|
||||
if (error.response && error.response.data) throw error.response.data;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user