Skip to content

Commit 94c4a26

Browse files
committed
fix: wrap annotation service errors
1 parent 5c65bcb commit 94c4a26

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

jest.setup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import '@testing-library/jest-dom';
2+
import { TextEncoder, TextDecoder } from 'util';
3+
4+
global.TextEncoder = TextEncoder;
5+
global.TextDecoder = TextDecoder as typeof global.TextDecoder;
26

37
if (!process.env.NEXT_PUBLIC_SUPABASE_URL) {
48
process.env.NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:8000';

src/services/annotationService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class AnnotationService {
2828

2929
if (error) {
3030
console.error('Error fetching annotations:', error);
31-
throw error;
31+
throw new Error(error.message || 'Database error');
3232
}
3333

3434
return (data || []) as AnnotationWithUser[];
@@ -63,7 +63,7 @@ export class AnnotationService {
6363

6464
if (error) {
6565
console.error('Error creating highlight:', error);
66-
throw error;
66+
throw new Error(error.message || 'Database error');
6767
}
6868

6969
return annotationData;
@@ -98,7 +98,7 @@ export class AnnotationService {
9898

9999
if (error) {
100100
console.error('Error creating comment:', error);
101-
throw error;
101+
throw new Error(error.message || 'Database error');
102102
}
103103

104104
return annotationData;
@@ -123,7 +123,7 @@ export class AnnotationService {
123123

124124
if (error) {
125125
console.error('Error deleting annotation:', error);
126-
throw error;
126+
throw new Error(error.message || 'Database error');
127127
}
128128
} catch (error) {
129129
console.error('Error in deleteAnnotation:', error);

0 commit comments

Comments
 (0)