-
-
Notifications
You must be signed in to change notification settings - Fork 299
Expand file tree
/
Copy pathError.ts
More file actions
489 lines (422 loc) · 15.6 KB
/
Error.ts
File metadata and controls
489 lines (422 loc) · 15.6 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
import { Bookmark, TItemLocation } from '../lib/Tree'
export class FloccusError extends Error {
public readonly code: number
constructor(message) {
super(message)
// See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript#22666069
Object.setPrototypeOf(this, FloccusError.prototype)
}
}
export class TransientError extends FloccusError {
constructor(message) {
super(message)
Object.setPrototypeOf(this, TransientError.prototype)
}
}
export class UnknownCreateTargetError extends FloccusError {
public readonly code = 1
constructor() {
super("E001: Folder to create in doesn't exist")
Object.setPrototypeOf(this, UnknownCreateTargetError.prototype)
}
}
export class UnknownBookmarkUpdateError extends TransientError {
public readonly code = 2
constructor() {
super("E002: Bookmark to update doesn't exist anymore")
Object.setPrototypeOf(this, UnknownBookmarkUpdateError.prototype)
}
}
export class UnknownMoveOriginError extends TransientError {
public readonly code = 3
constructor() {
super("E003: Folder to move out of doesn't exist")
Object.setPrototypeOf(this, UnknownMoveOriginError.prototype)
}
}
export class UnknownMoveTargetError extends FloccusError {
public readonly code = 4
constructor() {
super("E004: Folder to move into doesn't exist")
Object.setPrototypeOf(this, UnknownMoveTargetError.prototype)
}
}
export class UnknownFolderParentUpdateError extends TransientError {
public readonly code = 5
constructor() {
super("E006: Parent of folder to update doesn't exist")
Object.setPrototypeOf(this, UnknownFolderParentUpdateError.prototype)
}
}
export class UnknownFolderUpdateError extends TransientError {
public readonly code = 6
constructor() {
super("E006: Folder to update doesn't exist")
Object.setPrototypeOf(this, UnknownFolderUpdateError.prototype)
}
}
export class UnknownFolderMoveError extends TransientError {
public readonly code = 7
constructor() {
super("E007: Folder to move doesn't exist")
Object.setPrototypeOf(this, UnknownFolderMoveError.prototype)
}
}
// code 8 is unused
// code 9 is unused
export class UnknownFolderOrderError extends TransientError {
public readonly code = 10
constructor() {
super('E010: Could not find folder to order')
Object.setPrototypeOf(this, UnknownFolderOrderError.prototype)
}
}
export class UnknownFolderItemOrderError extends FloccusError {
public item: string
public readonly code = 11
constructor(item: string) {
super('E011: Item in folder ordering is not an actual child')
this.item = item
Object.setPrototypeOf(this, UnknownFolderItemOrderError.prototype)
}
}
export class MissingItemOrderError extends FloccusError {
public item: string
public readonly code = 12
constructor(item: string) {
super("E012: Folder ordering is missing some of the folder's children")
this.item = item
Object.setPrototypeOf(this, MissingItemOrderError.prototype)
}
}
export class UnknownFolderRemoveError extends TransientError {
public readonly code = 13
constructor() {
super("E013: Folder to remove doesn't exist")
Object.setPrototypeOf(this, UnknownFolderRemoveError.prototype)
}
}
export class UnknownFolderParentRemoveError extends FloccusError {
public readonly code = 14
constructor() {
super("E014: Parent folder to remove folder from doesn't exist")
Object.setPrototypeOf(this, UnknownFolderParentRemoveError.prototype)
}
}
export class UnexpectedServerResponseError extends TransientError {
public readonly code = 15
constructor() {
super('E015: Unexpected response data from server')
Object.setPrototypeOf(this, UnexpectedServerResponseError.prototype)
}
}
export class RequestTimeoutError extends TransientError {
public readonly code = 16
constructor() {
super('E016: Request timed out.')
Object.setPrototypeOf(this, RequestTimeoutError.prototype)
}
}
export class NetworkError extends TransientError {
public readonly code = 17
constructor() {
super(
'E017: Network error: Check your network connection and your profile details'
)
Object.setPrototypeOf(this, NetworkError.prototype)
}
}
export class AuthenticationError extends FloccusError {
public readonly code = 18
constructor() {
super("E018: Couldn't authenticate with the server.")
Object.setPrototypeOf(this, AuthenticationError.prototype)
}
}
export class HttpError extends TransientError {
public readonly code = 19
public status: number
public method: string
constructor(status: number, method: string) {
super(
`E019: HTTP status ${status}. Failed ${method} request. Check your server configuration and log.`
)
this.status = status
this.method = method
Object.setPrototypeOf(this, HttpError.prototype)
}
}
export class ParseResponseError extends TransientError {
public readonly code = 20
public response: string
constructor(response: string) {
super('E020: Could not parse server response.')
this.response = response
Object.setPrototypeOf(this, ParseResponseError.prototype)
}
}
export class InconsistentServerStateError extends TransientError {
public readonly code = 21
constructor() {
super(
'E021: Inconsistent server state. Folder is present in childorder list but not in folder tree'
)
Object.setPrototypeOf(this, InconsistentServerStateError.prototype)
}
}
export class InconsistentBookmarksExistenceError extends TransientError {
public readonly code = 22
public folder: string
public bookmark: string
constructor(folder: string, bookmark: string) {
super(
`E022: Folder ${folder} supposedly contains non-existent bookmark ${bookmark}`
)
this.folder = folder
this.bookmark = bookmark
Object.setPrototypeOf(this, InconsistentBookmarksExistenceError.prototype)
}
}
export class UnclearedLockFileError extends FloccusError {
public readonly code = 23
public lockFile: string
constructor(lockFile:string) {
super(`E023: Unable to clear lock file, consider deleting ${lockFile} manually.`)
this.lockFile = lockFile
Object.setPrototypeOf(this, UnclearedLockFileError.prototype)
}
}
export class LockFileError extends FloccusError {
public readonly code = 24
public status: number
public lockFile: string
constructor(status:number, lockFile:string) {
super(`E024: HTTP status ${status} while trying to determine status of lock file ${lockFile}`)
this.status = status
this.lockFile = lockFile
Object.setPrototypeOf(this, LockFileError.prototype)
}
}
export class SlashError extends FloccusError {
public readonly code = 25
public status: number
public lockFile: string
constructor() {
super("E025: Bookmarks file setting mustn't begin with a slash: '/'")
Object.setPrototypeOf(this, SlashError.prototype)
}
}
export class CancelledSyncError extends FloccusError {
public readonly code = 26
constructor() {
super('E026: Sync process was cancelled')
Object.setPrototypeOf(this, CancelledSyncError.prototype)
}
}
export class InterruptedSyncError extends TransientError {
public readonly code = 27
constructor() {
super('E027: Sync process was interrupted')
Object.setPrototypeOf(this, InterruptedSyncError.prototype)
}
}
// code 28 is unused
export class ServersideDeletionFailsafeError extends FloccusError {
public readonly code = 29
public percent: number
constructor(percent:number) {
super(`E029: Failsafe: The current sync run would delete ${percent}% of your links on the server. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
this.percent = percent
Object.setPrototypeOf(this, ServersideDeletionFailsafeError.prototype)
}
}
export class DecryptionError extends FloccusError {
public readonly code = 30
constructor() {
super('E030: Failed to decrypt bookmarks file. The passphrase may be wrong or the file may be corrupted.')
Object.setPrototypeOf(this, DecryptionError.prototype)
}
}
export class GoogleDriveAuthenticationError extends FloccusError {
public readonly code = 31
constructor() {
super('E031: Could not authenticate with Google Drive. Please connect floccus with your google account again.')
Object.setPrototypeOf(this, GoogleDriveAuthenticationError.prototype)
}
}
export class GoogleOAuthTokenError extends FloccusError {
public readonly code = 32
constructor() {
super('E032: OAuth error. Token validation error. Please reconnect your Google Account.')
Object.setPrototypeOf(this, GoogleOAuthTokenError.prototype)
}
}
export class RedirectError extends FloccusError {
public readonly code = 33
constructor() {
super("E033: Redirect detected. Please make sure the server supports the selected sync method and URL you entered is correct doesn't redirect to a different location.")
Object.setPrototypeOf(this, RedirectError.prototype)
}
}
export class FileUnreadableError extends FloccusError {
public readonly code = 34
constructor() {
super('E034: Remote bookmarks file is unreadable. Perhaps you forgot to set an encryption passphrase, or you set the wrong file format.')
Object.setPrototypeOf(this, FileUnreadableError.prototype)
}
}
export class CreateBookmarkError extends FloccusError {
public readonly code = 35
public bookmark: Bookmark<TItemLocation>
constructor(bookmark: Bookmark<TItemLocation>) {
super(`E035: Failed to create the following bookmark on the server: ${bookmark.inspect()} -- Is the bookmarks app up to date?`)
this.bookmark = bookmark
Object.setPrototypeOf(this, CreateBookmarkError.prototype)
}
}
export class MissingPermissionsError extends FloccusError {
public readonly code = 36
constructor() {
super(`E036: Missing permissions to access the sync server`)
Object.setPrototypeOf(this, MissingPermissionsError.prototype)
}
}
export class ResourceLockedError extends FloccusError {
public readonly code = 37
constructor() {
super(`E037: Resource is locked`)
Object.setPrototypeOf(this, ResourceLockedError.prototype)
}
}
export class LocalFolderNotFoundError extends FloccusError {
public readonly code = 38
constructor() {
super(`E038: Could not find local folder`)
Object.setPrototypeOf(this, LocalFolderNotFoundError.prototype)
}
}
export class UpdateBookmarkError extends FloccusError {
public readonly code = 39
public bookmark: Bookmark<TItemLocation>
constructor(bookmark: Bookmark<TItemLocation>) {
super(`E039: Failed to update the following bookmark on the server: ${bookmark.inspect()}`)
this.bookmark = bookmark
Object.setPrototypeOf(this, UpdateBookmarkError.prototype)
}
}
export class GoogleDriveSearchError extends FloccusError {
public readonly code = 40
constructor() {
super('E040: Could not search for your file name in your Google Drive')
Object.setPrototypeOf(this, GoogleDriveSearchError.prototype)
}
}
export class FileSizeMismatch extends TransientError {
public readonly code = 41
constructor() {
super(
'E041: Remote bookmarks file size differs from the content that was actually downloaded from the server. This might be a temporary network issue. If this error persists please contact the server administrator.'
)
Object.setPrototypeOf(this, FileSizeMismatch.prototype)
}
}
export class FileSizeUnknown extends FloccusError {
public readonly code = 42
constructor() {
super('E042: Remote bookmarks file size could not be retrieved. It is impossible to verify that the bookmarks file was downloaded in full. If this error persists please contact the server administrator.')
Object.setPrototypeOf(this, FileSizeUnknown.prototype)
}
}
export class ServersideAdditionFailsafeError extends FloccusError {
public readonly code = 43
public percent: number
constructor(percent:number) {
super(`E043: Failsafe: The current sync run would increase your links count on the server by ${percent}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
this.percent = percent
Object.setPrototypeOf(this, ServersideAdditionFailsafeError.prototype)
}
}
export class GitPushError extends FloccusError {
public readonly code = 44
public errorMessage: string
constructor(errorMessage:string) {
super(`E044: Git push operation failed: ${errorMessage}`)
this.errorMessage = errorMessage
Object.setPrototypeOf(this, GitPushError.prototype)
}
}
export class UnexpectedFolderPathError extends FloccusError {
public readonly code = 45
public originalPath: string
public newPath: string
constructor(originalPath: string, newPath: string) {
super(`E045: Unexpected folder path. The local sync folder for this profile used to be at '${originalPath}' but is now at '${newPath}'. Please make sure this is intended and set the local sync folder again in the profile settings.`)
this.originalPath = originalPath
this.newPath = newPath
Object.setPrototypeOf(this, UnexpectedFolderPathError.prototype)
}
}
export class InvalidUrlError extends FloccusError {
public readonly code = 46
public url: string
constructor(url: string) {
super(`E046: Invalid URL. '${url}' is not a valid URL.`)
this.url = url
Object.setPrototypeOf(this, InvalidUrlError.prototype)
}
}
export class XbelParseError extends FloccusError {
public readonly code = 47
constructor() {
super(`E047: Failed to parse XBEL file. The XBEL data seems to be corrupted or incomplete. You can try removing the file on the server to let floccus recreate it. Make sure to take a backup first.`)
Object.setPrototypeOf(this, XbelParseError.prototype)
}
}
export class MappingFailureError extends FloccusError {
public readonly code = 48
public id: string
constructor(id: string) {
super(`E048: Failed to map ID: ${id}`)
this.id = id
Object.setPrototypeOf(this, MappingFailureError.prototype)
}
}
export class ClientsideAdditionFailsafeError extends FloccusError {
public readonly code = 49
public percent: number
constructor(percent:number) {
super(`E049: Failsafe: The current sync run would increase your local links count in this profile by ${percent}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
this.percent = percent
Object.setPrototypeOf(this, ClientsideAdditionFailsafeError.prototype)
}
}
export class ClientsideDeletionFailsafeError extends FloccusError {
public readonly code = 50
public percent: number
constructor(percent:number) {
super(`E050: Failsafe: The current sync run would delete ${percent}% of your local links in this profile. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
this.percent = percent
Object.setPrototypeOf(this, ClientsideDeletionFailsafeError.prototype)
}
}
export class OneDriveAuthenticationError extends FloccusError {
public readonly code = 51
constructor() {
super('E051: Could not authenticate with OneDrive. Please connect floccus with your OneDrive account again.')
Object.setPrototypeOf(this, OneDriveAuthenticationError.prototype)
}
}
export class OneDriveOAuthTokenError extends FloccusError {
public readonly code = 52
constructor() {
super('E052: OAuth error. Token validation error. Please reconnect your OneDrive Account.')
Object.setPrototypeOf(this, OneDriveOAuthTokenError.prototype)
}
}
export class OneDriveSearchError extends FloccusError {
public readonly code = 53
constructor() {
super('E053: Could not search for your file name in your OneDrive')
Object.setPrototypeOf(this, OneDriveSearchError.prototype)
}
}