-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
141 lines (137 loc) · 4.11 KB
/
Copy patherrors.js
File metadata and controls
141 lines (137 loc) · 4.11 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* Error Handling for stdout-setup
*
* Simplified version of the StdOut error framework for the installer.
*/
export const ERROR_CODES = {
E1001: {
code: 'E1001',
userMessage: "The email address doesn't match this license key.",
actions: [
'Check your purchase confirmation email for the correct license key',
'Verify you\'re using the same email address from your purchase',
'Contact support@seayniclabs.com if you need help',
],
},
E1002: {
code: 'E1002',
userMessage: 'This license has expired.',
actions: [
'Contact support@seayniclabs.com to renew your license',
'Check your account at https://store.seayniclabs.com for renewal options',
],
},
E1003: {
code: 'E1003',
userMessage: 'License server is unreachable. Check your internet connection.',
actions: [
'Verify your internet connection is working',
'Check if stdout-licenses.fly.dev is accessible',
'Wait a moment and try again',
],
},
E1004: {
code: 'E1004',
userMessage: 'License activation limit reached.',
actions: [
'You\'ve used all available activations for this license',
'Deactivate StdOut on another machine to free up an activation slot',
'Contact support@seayniclabs.com to increase your activation limit',
],
},
E2001: {
code: 'E2001',
userMessage: 'Docker is not running on this machine.',
actions: [
'Start Docker Desktop (macOS/Windows) or dockerd (Linux)',
'Verify Docker is installed: docker --version',
'Check Docker service status',
],
},
E2002: {
code: 'E2002',
userMessage: 'Failed to download container images. Check your internet connection.',
actions: [
'Verify your internet connection is working',
'Check if hub.docker.com (Docker Hub) is accessible',
'Retry the installation',
],
},
E2003: {
code: 'E2003',
userMessage: 'Port 8112 is already in use by another application.',
actions: [
'Stop the application using port 8112',
'Find what\'s using the port: lsof -i :8112 (macOS/Linux)',
'Or, edit docker-compose.yml to use a different port',
],
},
E3001: {
code: 'E3001',
userMessage: 'Database initialization failed.',
actions: [
'Check disk space is available',
'Verify the data directory is writable',
'Retry the installation',
'If persists, contact support@seayniclabs.com with error code E3001',
],
},
E4001: {
code: 'E4001',
userMessage: 'Invalid email address format.',
actions: ['Enter a valid email address (e.g., user@example.com)'],
},
E4002: {
code: 'E4002',
userMessage: 'Password is too weak. Minimum 8 characters required.',
actions: [
'Use a password with at least 8 characters',
'Include a mix of letters, numbers, and symbols for better security',
],
},
};
export class InstallationError extends Error {
constructor(code, context = {}) {
const definition = ERROR_CODES[code];
if (!definition) {
super('An unexpected error occurred');
this.code = 'E9999';
this.actions = ['Contact support@seayniclabs.com with error code E9999'];
} else {
super(definition.userMessage);
this.code = code;
this.actions = definition.actions;
}
this.context = context;
this.timestamp = new Date().toISOString();
}
toJSON() {
return {
type: 'error',
code: this.code,
error: this.message,
actions: this.actions,
context: this.context,
timestamp: this.timestamp,
};
}
}
/**
* Map raw API errors to error codes
*/
export function mapLicenseError(apiError) {
if (apiError.includes('Email does not match')) {
return new InstallationError('E1001');
}
if (apiError.includes('expired')) {
return new InstallationError('E1002');
}
if (apiError.includes('activation limit')) {
return new InstallationError('E1004');
}
if (apiError.includes('unreachable') || apiError.includes('timeout')) {
return new InstallationError('E1003');
}
// Unknown license error
return new InstallationError('E9999', { originalError: apiError });
}