github.com/tompreston/snapd@v0.0.0-20210817193607-954edfcb9611/client/errors.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2020 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package client 21 22 // ErrorKind distinguishes kind of errors. 23 type ErrorKind string 24 25 // error kind const value doc comments here have a non-default, 26 // specialized style (to help docs/error-kind.go): 27 // 28 // // ErrorKind...: DESCRIPTION . 29 // 30 // Note the mandatory dot at the end. 31 // `code-like` quoting should be used when meaningful. 32 33 // Error kinds. Keep https://forum.snapcraft.io/t/using-the-rest-api/18603#heading--errors in sync using doc/error-kinds.go. 34 const ( 35 // ErrorKindTwoFactorRequired: the client needs to retry the 36 // `login` command including an OTP. 37 ErrorKindTwoFactorRequired ErrorKind = "two-factor-required" 38 // ErrorKindTwoFactorFailed: the OTP provided wasn't recognised. 39 ErrorKindTwoFactorFailed ErrorKind = "two-factor-failed" 40 // ErrorKindLoginRequired: the requested operation cannot be 41 // performed without an authenticated user. This is the kind 42 // of any other 401 Unauthorized response. 43 ErrorKindLoginRequired ErrorKind = "login-required" 44 // ErrorKindInvalidAuthData: the authentication data provided 45 // failed to validate (e.g. a malformed email address). The 46 // `value` of the error is an object with a key per failed field 47 // and a list of the failures on each field. 48 ErrorKindInvalidAuthData ErrorKind = "invalid-auth-data" 49 // ErrorKindPasswordPolicy: provided password doesn't meet 50 // system policy. 51 ErrorKindPasswordPolicy ErrorKind = "password-policy" 52 // ErrorKindAuthCancelled: authentication was cancelled by the user. 53 ErrorKindAuthCancelled ErrorKind = "auth-cancelled" 54 55 // ErrorKindTermsNotAccepted: deprecated, do not document. 56 ErrorKindTermsNotAccepted ErrorKind = "terms-not-accepted" 57 // ErrorKindNoPaymentMethods: deprecated, do not document. 58 ErrorKindNoPaymentMethods ErrorKind = "no-payment-methods" 59 // ErrorKindPaymentDeclined: deprecated, do not document. 60 ErrorKindPaymentDeclined ErrorKind = "payment-declined" 61 62 // ErrorKindSnapAlreadyInstalled: the requested snap is 63 // already installed. 64 ErrorKindSnapAlreadyInstalled ErrorKind = "snap-already-installed" 65 // ErrorKindSnapNotInstalled: the requested snap is not installed. 66 ErrorKindSnapNotInstalled ErrorKind = "snap-not-installed" 67 // ErrorKindSnapNotFound: the requested snap couldn't be found. 68 ErrorKindSnapNotFound ErrorKind = "snap-not-found" 69 // ErrorKindAppNotFound: the requested app couldn't be found. 70 ErrorKindAppNotFound ErrorKind = "app-not-found" 71 // ErrorKindSnapLocal: cannot perform operation on local snap. 72 ErrorKindSnapLocal ErrorKind = "snap-local" 73 // ErrorKindSnapNeedsDevMode: the requested snap needs devmode 74 // to be installed. 75 ErrorKindSnapNeedsDevMode ErrorKind = "snap-needs-devmode" 76 // ErrorKindSnapNeedsClassic: the requested snap needs classic 77 // confinement to be installed. 78 ErrorKindSnapNeedsClassic ErrorKind = "snap-needs-classic" 79 // ErrorKindSnapNeedsClassicSystem: the requested snap can't 80 // be installed on the current non-classic system. 81 ErrorKindSnapNeedsClassicSystem ErrorKind = "snap-needs-classic-system" 82 // ErrorKindSnapNotClassic: snap not compatible with classic mode. 83 ErrorKindSnapNotClassic ErrorKind = "snap-not-classic" 84 // ErrorKindSnapNoUpdateAvailable: the requested snap does not 85 // have an update available. 86 ErrorKindSnapNoUpdateAvailable ErrorKind = "snap-no-update-available" 87 // ErrorKindSnapRevisionNotAvailable: no snap revision available 88 // as specified. 89 ErrorKindSnapRevisionNotAvailable ErrorKind = "snap-revision-not-available" 90 // ErrorKindSnapChannelNotAvailable: no snap revision on specified 91 // channel. The `value` of the error is a rich object with 92 // requested `snap-name`, `action`, `channel`, `architecture`, and 93 // actually available `releases` as list of 94 // `{"architecture":... , "channel": ...}` objects. 95 ErrorKindSnapChannelNotAvailable ErrorKind = "snap-channel-not-available" 96 // ErrorKindSnapArchitectureNotAvailable: no snap revision on 97 // specified architecture. Value has the same format as for 98 // `snap-channel-not-available`. 99 ErrorKindSnapArchitectureNotAvailable ErrorKind = "snap-architecture-not-available" 100 101 // ErrorKindSnapChangeConflict: the requested operation would 102 // conflict with currently ongoing change. This is a temporary 103 // error. The error `value` is an object with optional fields 104 // `snap-name`, `change-kind` of the ongoing change. 105 ErrorKindSnapChangeConflict ErrorKind = "snap-change-conflict" 106 107 // ErrorKindQuotaChangeConflict: the requested operation would 108 // conflict with a currently ongoing change affecting the quota 109 // group. This is a temporary error. The error `value` is an 110 // object with optional fields `quota-name`, `change-kind` of the 111 // ongoing change. 112 ErrorKindQuotaChangeConflict ErrorKind = "quota-change-conflict" 113 114 // ErrorKindNotSnap: the given snap or directory does not 115 // look like a snap. 116 ErrorKindNotSnap ErrorKind = "snap-not-a-snap" 117 118 // ErrorKindInterfacesUnchanged: the requested interfaces' 119 // operation would have no effect. 120 ErrorKindInterfacesUnchanged ErrorKind = "interfaces-unchanged" 121 122 // ErrorKindBadQuery: a bad query was provided. 123 ErrorKindBadQuery ErrorKind = "bad-query" 124 // ErrorKindConfigNoSuchOption: the given configuration option 125 // does not exist. 126 ErrorKindConfigNoSuchOption ErrorKind = "option-not-found" 127 128 // ErrorKindAssertionNotFound: assertion can not be found. 129 ErrorKindAssertionNotFound ErrorKind = "assertion-not-found" 130 131 // ErrorKindUnsuccessful: snapctl command was unsuccessful. 132 ErrorKindUnsuccessful ErrorKind = "unsuccessful" 133 134 // ErrorKindNetworkTimeout: a timeout occurred during the request. 135 ErrorKindNetworkTimeout ErrorKind = "network-timeout" 136 137 // ErrorKindDNSFailure: DNS not responding. 138 ErrorKindDNSFailure ErrorKind = "dns-failure" 139 140 // ErrorKindInsufficientDiskSpace: not enough disk space to perform the request. 141 ErrorKindInsufficientDiskSpace ErrorKind = "insufficient-disk-space" 142 143 // ErrorKindValidationSetNotFound: validation set cannot be found. 144 ErrorKindValidationSetNotFound ErrorKind = "validation-set-not-found" 145 ) 146 147 // Maintenance error kinds. 148 // These are used only inside the maintenance field of responses. 149 // Keep https://forum.snapcraft.io/t/using-the-rest-api/18603#heading--maint-errors in sync using doc/error-kinds.go. 150 const ( 151 // ErrorKindDaemonRestart: daemon is restarting. 152 ErrorKindDaemonRestart ErrorKind = "daemon-restart" 153 // ErrorKindSystemRestart: system is restarting. 154 ErrorKindSystemRestart ErrorKind = "system-restart" 155 )