github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/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 // ErrorKindNotSnap: the given snap or directory does not 108 // look like a snap. 109 ErrorKindNotSnap ErrorKind = "snap-not-a-snap" 110 111 // ErrorKindInterfacesUnchanged: the requested interfaces' 112 // operation would have no effect. 113 ErrorKindInterfacesUnchanged ErrorKind = "interfaces-unchanged" 114 115 // ErrorKindBadQuery: a bad query was provided. 116 ErrorKindBadQuery ErrorKind = "bad-query" 117 // ErrorKindConfigNoSuchOption: the given configuration option 118 // does not exist. 119 ErrorKindConfigNoSuchOption ErrorKind = "option-not-found" 120 121 // ErrorKindAssertionNotFound: assertion can not be found. 122 ErrorKindAssertionNotFound ErrorKind = "assertion-not-found" 123 124 // ErrorKindUnsuccessful: snapctl command was unsuccessful. 125 ErrorKindUnsuccessful ErrorKind = "unsuccessful" 126 127 // ErrorKindNetworkTimeout: a timeout occurred during the request. 128 ErrorKindNetworkTimeout ErrorKind = "network-timeout" 129 130 // ErrorKindDNSFailure: DNS not responding. 131 ErrorKindDNSFailure ErrorKind = "dns-failure" 132 133 // ErrorKindInsufficientDiskSpace: not enough disk space to perform the request. 134 ErrorKindInsufficientDiskSpace ErrorKind = "insufficient-disk-space" 135 ) 136 137 // Maintenance error kinds. 138 // These are used only inside the maintenance field of responses. 139 // Keep https://forum.snapcraft.io/t/using-the-rest-api/18603#heading--maint-errors in sync using doc/error-kinds.go. 140 const ( 141 // ErrorKindDaemonRestart: daemon is restarting. 142 ErrorKindDaemonRestart ErrorKind = "daemon-restart" 143 // ErrorKindSystemRestart: system is restarting. 144 ErrorKindSystemRestart ErrorKind = "system-restart" 145 )