diff --git a/backend/src/controller/scans/mod.rs b/backend/src/controller/scans/mod.rs index 9f3eaf0..be5a03a 100644 --- a/backend/src/controller/scans/mod.rs +++ b/backend/src/controller/scans/mod.rs @@ -70,7 +70,7 @@ fn get_valid_files() -> Result, String> { Ok(paths) => paths, Err(err) => { log::error!("Error reading dir: {:?}", err); - return Err("Error leyendo directorio".into()); + return Err("Error abriendo carpeta ESCANEOS".into()); } }; @@ -81,7 +81,7 @@ fn get_valid_files() -> Result, String> { Ok(p) => p, Err(err) => { log::error!("Error reading path: {:?}", err); - return Err("Error recuperando archivo de lista de archivos".into()); + return Err("Error leyendo archivos en ESCANEOS".into()); } }; @@ -96,7 +96,7 @@ fn get_valid_files() -> Result, String> { Some(filename) => filename, None => { log::error!("Error getting file name: {:?}", file_path); - return Err("Error leyendo archivo en directorio".into()); + return Err("Error leyendo archivo en ESCANEOS".into()); } }; @@ -162,7 +162,7 @@ fn get_image_info(path: PathBuf) -> ScanInfo { let current_time = match current_time { Ok(t) => t, Err(err) => { - log::error!("Error obteniendo hora actual: {:?}", err); + log::error!("Error getting time, TIME WENT BACKWARDS: {:?}", err); return ScanInfo::Error("Error obteniendo hora actual: TIME WENT BACKWARDS.".into()); } }; @@ -191,7 +191,7 @@ fn get_image_info(path: PathBuf) -> ScanInfo { // If no QR is detected, only rename if results.is_empty() { - log::info!("QR not found"); + log::info!("QR not found, only renaming"); // Rename file let mut new_path = path.clone(); @@ -202,7 +202,7 @@ fn get_image_info(path: PathBuf) -> ScanInfo { Err(err) => { log::error!("Error renombrando archivo: {:?}", err); - ScanInfo::Error("Error renombrando archivo.".into()) + ScanInfo::Error("Error renombrando archivo sin QR detectado.".into()) } }; } @@ -222,7 +222,7 @@ fn get_image_info(path: PathBuf) -> ScanInfo { Err(err) => { log::error!("Error renombrando archivo: {:?}", err); - ScanInfo::Error("Error renombrando archivo.".into()) + ScanInfo::Error("Error renombrando archivo sin QR detectado.".into()) } }; } @@ -241,7 +241,7 @@ fn get_image_info(path: PathBuf) -> ScanInfo { Some(p) => p, None => { return ScanInfo::Error( - "QR invalido: Tiene signo de interrogacion (?) pero no igual (=).".into(), + "QR invalido: La URL tiene signo de interrogacion (?) pero no igual (=).".into(), ) } }; @@ -264,7 +264,7 @@ fn get_image_info(path: PathBuf) -> ScanInfo { } } } - Err(_) => ScanInfo::Error("QR invalido: El iid no es un número.".into()), + Err(_) => ScanInfo::Error("QR invalido: El iid de la URL no es un número.".into()), } } None => { @@ -320,7 +320,7 @@ async fn convert_scans_from_data(data: &Vec) -> Result<(), String> { Ok(v) => v, Err(err) => { log::error!("Error getting persons info: {:?}", err); - return Err("Error obteniendo información de personas.".into()); + return Err(format!("Error obteniendo información de personas. {}", err)); } }; @@ -436,7 +436,7 @@ fn convert_to_pdf(image_path: &PathBuf, output_path: &PathBuf) -> Result<(), Str Ok(r) => r, Err(err) => { log::error!("Error starting imagemagick: {:?}", err); - return Err(format!("Error convirtiendo imagen")); + return Err(format!("Error inicializando ImageMagick")); } }; @@ -445,12 +445,12 @@ fn convert_to_pdf(image_path: &PathBuf, output_path: &PathBuf) -> Result<(), Str Ok(exit_status) => { log::error!("Error calling imagemagick: {:?}", exit_status); Err(format!( - "Error ejecutando imagemagick: codigo de salida no exitoso" + "Error ejecutando ImageMagick: codigo de salida no exitoso" )) } Err(err) => { log::error!("Error calling imagemagick: {:?}", err); - Err(format!("Error ejecutando imagemagick")) + Err(format!("Error ejecutando ImageMagick")) } } } diff --git a/backend/src/model/register.rs b/backend/src/model/register.rs index 10b88d6..692ec1d 100644 --- a/backend/src/model/register.rs +++ b/backend/src/model/register.rs @@ -253,7 +253,6 @@ impl Register { let result = match db.fetch_all(sql.as_str()).await { Ok(res) => res, Err(err) => { - drop(sqlx::Error::PoolTimedOut); log::error!("Error fetching course & person: {:?}", err); return Err("Error fetching course & person".into()); } diff --git a/frontend/src/Scans/ScansList.tsx b/frontend/src/Scans/ScansList.tsx index 72f60fe..12d8a3c 100644 --- a/frontend/src/Scans/ScansList.tsx +++ b/frontend/src/Scans/ScansList.tsx @@ -6,6 +6,8 @@ import { LoadingIcon } from "../icons/LoadingIcon"; import { PDFIcon } from "../icons/PDFIcon"; import { LoadingStatus, useLoading } from "../utils/functions"; import { QuestionIcon } from "../icons/QuestionIcon"; +import axios from "axios"; +import { JsonResult } from "../types/JsonResult"; export function ScansList(props: {scanData: Array | null, onSuccess: () => void}) { const {status, setStatus, error, setError} = useLoading(); @@ -45,24 +47,21 @@ export function ScansList(props: {scanData: Array | null, onSuccess: return; } - fetch( - `${import.meta.env.VITE_BACKEND_URL}/api/scans/convert`, - { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(props.scanData), - }, - ) - .then((res) => res.json()) + axios.post(`${import.meta.env.VITE_BACKEND_URL}/api/scans/convert`, props.scanData) .then(() => { setStatus(LoadingStatus.Ok); props.onSuccess(); }) .catch((err) => { - setStatus(LoadingStatus.Error); console.error(err); + setStatus(LoadingStatus.Error); + + if (err.response.data) { + const errorData = err.response.data as JsonResult; + console.error(errorData); + console.error(errorData.Error.reason); + setError(errorData.Error.reason); + } }); }; @@ -158,8 +157,10 @@ export function ScansList(props: {scanData: Array | null, onSuccess:
-

- Error convirtiendo PDFs: {error()} +

+ Error fatal convirtiendo PDFs: +
+ {error()}