| 1 |
package errors |
| 2 |
|
| 3 |
import ( |
| 4 |
"os" |
| 5 |
) |
| 6 |
|
| 7 |
// Code exit code |
| 8 |
type Code int |
| 9 |
|
| 10 |
// Error codes that are sent to the browser extension and used as exit codes in the app. |
| 11 |
// DO NOT MODIFY THE VALUES, always append new error codes to the bottom. |
| 12 |
const ( |
| 13 |
CodeParseRequestLength Code = 10 |
| 14 |
CodeParseRequest Code = 11 |
| 15 |
CodeInvalidRequestAction Code = 12 |
| 16 |
CodeInaccessiblePasswordStore Code = 13 |
| 17 |
CodeInaccessibleDefaultPasswordStore Code = 14 |
| 18 |
CodeUnknownDefaultPasswordStoreLocation Code = 15 |
| 19 |
CodeUnreadablePasswordStoreDefaultSettings Code = 16 |
| 20 |
CodeUnreadableDefaultPasswordStoreDefaultSettings Code = 17 |
| 21 |
CodeUnableToListFilesInPasswordStore Code = 18 |
| 22 |
CodeUnableToDetermineRelativeFilePathInPasswordStore Code = 19 |
| 23 |
CodeInvalidPasswordStore Code = 20 |
| 24 |
CodeInvalidGpgPath Code = 21 |
| 25 |
CodeUnableToDetectGpgPath Code = 22 |
| 26 |
CodeInvalidPasswordFileExtension Code = 23 |
| 27 |
CodeUnableToDecryptPasswordFile Code = 24 |
| 28 |
) |
| 29 |
|
| 30 |
// Field extra field in the error response params |
| 31 |
type Field string |
| 32 |
|
| 33 |
// Extra fields that can be sent to the browser extension as part of an error response. |
| 34 |
// FieldMessage is always present, others are optional. |
| 35 |
const ( |
| 36 |
FieldMessage Field = "message" |
| 37 |
FieldAction Field = "action" |
| 38 |
FieldError Field = "error" |
| 39 |
FieldStoreID Field = "storeId" |
| 40 |
FieldStoreName Field = "storeName" |
| 41 |
FieldStorePath Field = "storePath" |
| 42 |
FieldFile Field = "file" |
| 43 |
FieldGpgPath Field = "gpgPath" |
| 44 |
) |
| 45 |
|
| 46 |
// ExitWithCode exit with error code |
| 47 |
func ExitWithCode(code Code) { |
| 48 |
os.Exit(int(code)) |
| 49 |
} |