forked from rocicorp/mono
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.ts
More file actions
43 lines (38 loc) · 1.53 KB
/
error.ts
File metadata and controls
43 lines (38 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import * as v from 'shared/src/valita.js';
// Note: Metric names depend on these values,
// so if you add or change on here a corresponding dashboard
// change will likely be needed.
export enum ErrorKind {
AuthInvalidated = 'AuthInvalidated',
ClientNotFound = 'ClientNotFound',
InvalidConnectionRequest = 'InvalidConnectionRequest',
InvalidConnectionRequestBaseCookie = 'InvalidConnectionRequestBaseCookie',
InvalidConnectionRequestLastMutationID = 'InvalidConnectionRequestLastMutationID',
InvalidConnectionRequestClientDeleted = 'InvalidConnectionRequestClientDeleted',
InvalidMessage = 'InvalidMessage',
InvalidPush = 'InvalidPush',
MutationFailed = 'MutationFailed',
Unauthorized = 'Unauthorized',
VersionNotSupported = 'VersionNotSupported',
Internal = 'Internal',
}
export const errorKindSchema = v.union(
v.literal(ErrorKind.AuthInvalidated),
v.literal(ErrorKind.ClientNotFound),
v.literal(ErrorKind.InvalidConnectionRequest),
v.literal(ErrorKind.InvalidConnectionRequestBaseCookie),
v.literal(ErrorKind.InvalidConnectionRequestLastMutationID),
v.literal(ErrorKind.InvalidConnectionRequestClientDeleted),
v.literal(ErrorKind.InvalidMessage),
v.literal(ErrorKind.InvalidPush),
v.literal(ErrorKind.MutationFailed),
v.literal(ErrorKind.Unauthorized),
v.literal(ErrorKind.VersionNotSupported),
v.literal(ErrorKind.Internal),
);
export const errorMessageSchema: v.Type<ErrorMessage> = v.tuple([
v.literal('error'),
errorKindSchema,
v.string(),
]);
export type ErrorMessage = ['error', ErrorKind, string];