forked from DataDog/datadog-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validation.ts
24 lines (20 loc) · 803 Bytes
/
validation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import {checkFile} from '../../helpers/validation'
import {RNSourcemap} from './interfaces'
export class InvalidPayload extends Error {
public reason: string
constructor(reason: string, message?: string) {
super(message)
this.reason = reason
}
}
export const validatePayload = (sourcemap: RNSourcemap) => {
// Check existence of sourcemap file
const sourcemapCheck = checkFile(sourcemap.sourcemapPath)
if (!sourcemapCheck.exists) {
// This case should not happen as all collected sourcemaps should point to correct files
throw new InvalidPayload('missing_sourcemap', `Skipping missing sourcemap (${sourcemap.sourcemapPath})`)
}
if (sourcemapCheck.empty) {
throw new InvalidPayload('empty_sourcemap', `Skipping empty sourcemap (${sourcemap.sourcemapPath})`)
}
}