summaryrefslogtreecommitdiffstats
path: root/src/features/offices/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/offices/hooks')
-rw-r--r--src/features/offices/hooks/useOffice.ts5
-rw-r--r--src/features/offices/hooks/useOffices.ts5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/features/offices/hooks/useOffice.ts b/src/features/offices/hooks/useOffice.ts
index 87d47b5..c737719 100644
--- a/src/features/offices/hooks/useOffice.ts
+++ b/src/features/offices/hooks/useOffice.ts
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { officesService } from '@/features/offices/services/officesService';
import { Office } from '@/features/offices/types';
+import { getErrorMessage } from '@/shared/lib/errors/getErrorMessage';
export function useOffice(officeId?: string) {
const [office, setOffice] = useState<Office | null>(null);
@@ -27,8 +28,8 @@ export function useOffice(officeId?: string) {
}
setOffice(data);
- } catch (err: any) {
- setError(err?.message ?? 'No se pudo cargar la oficina');
+ } catch (err) {
+ setError(getErrorMessage(err, 'No se pudo cargar la oficina'));
} finally {
setLoading(false);
}
diff --git a/src/features/offices/hooks/useOffices.ts b/src/features/offices/hooks/useOffices.ts
index ff08f6c..99f8f8e 100644
--- a/src/features/offices/hooks/useOffices.ts
+++ b/src/features/offices/hooks/useOffices.ts
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { officesService } from '@/features/offices/services/officesService';
import { Office } from '@/features/offices/types';
+import { getErrorMessage } from '@/shared/lib/errors/getErrorMessage';
export function useOffices() {
const [offices, setOffices] = useState<Office[]>([]);
@@ -14,8 +15,8 @@ export function useOffices() {
const data = await officesService.getAll();
setOffices(data);
- } catch (err: any) {
- setError(err?.message ?? 'No se pudieron cargar los espacios');
+ } catch (err) {
+ setError(getErrorMessage(err, 'No se pudieron cargar los espacios'));
} finally {
setLoading(false);
}