refactor(server:consume): change so error returns 200 so we can see the true error

This commit is contained in:
2025-03-10 16:32:02 -05:00
parent 40b970ef92
commit 0e579c84b5

View File

@@ -27,7 +27,7 @@ export const consumeMaterial = async (data: Data, prod: any) => {
if (barcode.length === 0) { if (barcode.length === 0) {
return { return {
success: false, success: false,
message: "The running number provided is not in stock please check if stock and try again.", message: "The running number you've is not in stock.",
}; };
//throw Error("The provided runningNr is not in stock"); //throw Error("The provided runningNr is not in stock");
} }
@@ -49,6 +49,6 @@ export const consumeMaterial = async (data: Data, prod: any) => {
//console.log(results); //console.log(results);
return {success: true, message: "Material was consumed", status: results.status}; return {success: true, message: "Material was consumed", status: results.status};
} catch (error: any) { } catch (error: any) {
return {success: false, status: error.response?.status, message: error.response?.data.errors[0].message}; return {success: false, status: 200, message: error.response?.data.errors[0].message};
} }
}; };