Files
snapd/snap/errors.go
John R. Lenton 6ca84e3228 many: slight improvement of some snap error messaging
There's still *so* much to do in this area. Still, in this branch:
* added an error kind "snap-local" for when the store returns
  ErrLocalSnap
* added an error kind "snap-not-found", for 404s
* dropped the store.NoUpdateAvailableError type in favour of
  store.ErrNoUpdateAvailable; the snap name contained in the error
  type could be wrong or misleading, and the client alreayd knows the
  name of the snap.
* moved cmd/snap's clientErrorToCmdMessage to errorToCmdMessage, and
  put the type checking in the function itself, to avoid repeating it
  for every caller. Still some more work to be done there before I'm
  happy with that.
* made cmd/snap's errorToCmdMessage take a *client.SnapOptions, which
  it can then use to better explain SnapNotFound.
* lastly, errorToCmdMessage handles snap-local.
2017-06-05 12:38:44 +01:00

51 lines
1.3 KiB
Go

// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2014-2016 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package snap
import "fmt"
type AlreadyInstalledError struct {
Snap string
}
func (e AlreadyInstalledError) Error() string {
return fmt.Sprintf("snap %q is already installed", e.Snap)
}
type NotInstalledError struct {
Snap string
Rev Revision
}
func (e NotInstalledError) Error() string {
if e.Rev.Unset() {
return fmt.Sprintf("snap %q is not installed", e.Snap)
}
return fmt.Sprintf("revision %s of snap %q is not installed", e.Rev, e.Snap)
}
type NotSnapError struct {
Path string
}
func (e NotSnapError) Error() string {
return fmt.Sprintf("%q is not a snap or snapdir", e.Path)
}