• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

formcapture / form-backend / 16905974748

12 Aug 2025 10:20AM UTC coverage: 65.766% (-2.5%) from 68.25%
16905974748

push

github

web-flow
Merge pull request #164 from formcapture/feat/errorhandling

Feat: Improve error handling in app and backend

308 of 556 branches covered (55.4%)

Branch coverage included in aggregate %.

86 of 140 new or added lines in 11 files covered. (61.43%)

19 existing lines in 1 file now uncovered.

812 of 1147 relevant lines covered (70.79%)

6.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.29
/backend/src/errors/GenericRequestError.ts
1
import { FormBackendErrorCode } from './FormBackendErrorCode';
9✔
2

3
interface ErrorInfo {
4
  errorCode?: FormBackendErrorCode;
5
  detailedMessage?: string;
6
}
7
interface DatabaseErrorInfo extends ErrorInfo {
8
  tableName?: string;
9
  dbErrorCode?: string;
10
}
11

12
export class GenericRequestError extends Error {
9✔
13
  status: number;
14
  extra?: ErrorInfo;
15

16
  constructor(message: string, status: number, extra: ErrorInfo) {
17
    super(message);
7✔
18
    this.name = 'GenericRequestError';
7✔
19
    this.message = message;
7✔
20
    this.status = status;
7✔
21
    this.extra = extra;
7✔
22
  }
23
}
24

25
export class InternalServerError extends GenericRequestError {
9✔
26
  constructor(message?: string) {
27
    super(message ?? 'Internal Server Error', 500, { errorCode: FormBackendErrorCode.INTERNAL_SERVER_ERROR });
1✔
28
    this.name = 'InternalServerError';
1✔
29
  }
30
}
31

32
export class DatabaseError extends GenericRequestError {
9✔
33
  constructor(message: string, extra: DatabaseErrorInfo) {
NEW
34
    super(message, 500, extra);
×
NEW
35
    this.name = 'DatabaseError';
×
36
  }
37
}
38

39
export class FormRequestError extends GenericRequestError {
9✔
40
  constructor(message: string, status: number, extra: ErrorInfo) {
NEW
41
    super(message, status, extra);
×
NEW
42
    this.name = 'FormRequestError';
×
43
  }
44
}
45

46
export function isGenericRequestError(err: any): err is GenericRequestError {
9✔
NEW
47
  return err instanceof GenericRequestError ||
×
48
    (err && err.name === 'GenericRequestError') ||
49
    (err && err.name === 'FormRequestError') ||
50
    (err && err.name === 'DatabaseError') ||
51
    (err && err.name === 'AuthenticationError') ||
52
    (err && err.name === 'InternalServerError');
53
}
54

55
export class AuthenticationError extends Error {
9✔
56
  status: number;
57

58
  constructor(message: string) {
59
    super(message);
10✔
60
    this.name = 'AuthenticationError';
10✔
61
    this.status = 401;
10✔
62
  }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc