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

opengovsg / FormSG / 9951990292

16 Jul 2024 06:53AM UTC coverage: 73.438% (+0.2%) from 73.22%
9951990292

push

github

Ken
chore: update dockerfile casing

2280 of 3864 branches covered (59.01%)

Branch coverage included in aggregate %.

9313 of 11922 relevant lines covered (78.12%)

43.09 hits per line

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

90.0
/src/app/modules/webhook/webhook.errors.ts
1
import { AxiosError } from 'axios'
2

3
import { ApplicationError, ErrorCodes } from '../core/core.errors'
150✔
4

5
/**
6
 * A custom error class thrown by the webhook server controller
7
 * if the submissionWebhookView is null or the webhookUrl is an invalid URL
8
 */
9
export class WebhookValidationError extends ApplicationError {
150✔
10
  constructor(message = 'Webhook URL is non-HTTPS or points to private IP') {
1✔
11
    super(message, undefined, ErrorCodes.WEBHOOK_VALIDATION)
18✔
12
  }
13
}
14

15
/**
16
 * Webhook failed to generate S3 presigned URLs for attachments
17
 */
18
export class WebhookFailedWithPresignedUrlGenerationError extends ApplicationError {
150✔
19
  meta: {
20
    originalError: unknown
21
  }
22

23
  constructor(error: unknown, message = 'Presigned Url Generation failed') {
×
24
    super(
×
25
      message,
26
      undefined,
27
      ErrorCodes.WEBHOOK_FAILED_WITH_PRESIGNED_URL_GENERATION,
28
    )
29
    this.meta = { originalError: error }
×
30
  }
31
}
32

33
/**
34
 * Webhook returned non-200 status, but error is not instance of AxiosError
35
 */
36
export class WebhookFailedWithUnknownError extends ApplicationError {
150✔
37
  meta: {
38
    originalError: unknown
39
  }
40

41
  constructor(error: unknown, message = 'Webhook POST failed') {
2✔
42
    super(message, undefined, ErrorCodes.WEBHOOK_FAILED_WITH_UNKNOWN_ERROR)
2✔
43
    this.meta = { originalError: error }
2✔
44
  }
45
}
46

47
/**
48
 * Webhook returned non-200 status, error is instance of AxiosError
49
 */
50
export class WebhookFailedWithAxiosError extends ApplicationError {
150✔
51
  meta: {
52
    originalError: AxiosError<unknown>
53
  }
54
  constructor(error: AxiosError<unknown>, message = 'Webhook POST failed') {
1✔
55
    super(message, undefined, ErrorCodes.WEBHOOK_FAILED_WITH_AXIOS_ERROR)
1✔
56
    this.meta = { originalError: error }
1✔
57
  }
58
}
59

60
/**
61
 * Webhook queue message incorrectly formatted and hence could not be parsed
62
 */
63
export class WebhookQueueMessageParsingError extends ApplicationError {
150✔
64
  meta: {
65
    originalError: unknown
66
  }
67

68
  constructor(
69
    error: unknown,
70
    message = 'Unable to parse body of webhook queue message',
4✔
71
  ) {
72
    super(message, undefined, ErrorCodes.WEBHOOK_QUEUE_MESSAGE_PARSING_ERROR)
4✔
73
    this.meta = { originalError: error }
4✔
74
  }
75
}
76

77
/**
78
 * Maximum retries exceeded for webhook.
79
 */
80
export class WebhookNoMoreRetriesError extends ApplicationError {
150✔
81
  constructor(message = 'Maximum retries exceeded for webhook') {
3✔
82
    super(message, undefined, ErrorCodes.WEBHOOK_NO_MORE_RETRIES)
3✔
83
  }
84
}
85

86
/**
87
 * Failed to push message to SQS.
88
 */
89
export class WebhookPushToQueueError extends ApplicationError {
150✔
90
  constructor(message = 'Failed to push webhook to message queue') {
14✔
91
    super(message, undefined, ErrorCodes.WEBHOOK_PUSH_TO_QUEUE)
14✔
92
  }
93
}
94

95
/**
96
 * Cannot send webhook retry because form has no webhook URL or does not have
97
 * retries enabled.
98
 */
99
export class WebhookRetriesNotEnabledError extends ApplicationError {
150✔
100
  meta: {
101
    webhookUrl: string
102
    isRetryEnabled: boolean
103
  }
104

105
  constructor(
106
    webhookUrl: string,
107
    isRetryEnabled: boolean,
108
    message = 'Unable to send webhook as form has no webhook URL or does not have retries enabled',
2✔
109
  ) {
110
    super(message, undefined, ErrorCodes.WEBHOOK_RETRIES_NOT_ENABLED)
2✔
111
    this.meta = {
2✔
112
      webhookUrl,
113
      isRetryEnabled,
114
    }
115
  }
116
}
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