2020-03-24 16:01:31 -05:00
|
|
|
// -*- Mode: Go; indent-tabs-mode: t -*-
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 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 boot
|
|
|
|
|
|
2020-08-24 11:12:08 -05:00
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
2020-04-09 11:36:14 -05:00
|
|
|
|
2020-03-24 16:01:31 -05:00
|
|
|
// trySnapError is an error that only applies to the try snaps where multiple
|
|
|
|
|
// snaps are returned, this is mainly and primarily used in revisions().
|
|
|
|
|
type trySnapError string
|
|
|
|
|
|
|
|
|
|
func (sre trySnapError) Error() string {
|
|
|
|
|
return string(sre)
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-09 11:36:14 -05:00
|
|
|
func newTrySnapErrorf(format string, args ...interface{}) error {
|
|
|
|
|
return trySnapError(fmt.Sprintf(format, args...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// isTrySnapError returns true if the given error is an error resulting from
|
2020-03-24 16:01:31 -05:00
|
|
|
// accessing information about the try snap or the trying status.
|
2020-04-09 11:36:14 -05:00
|
|
|
func isTrySnapError(err error) bool {
|
2020-03-24 16:01:31 -05:00
|
|
|
switch err.(type) {
|
2020-06-17 09:57:40 +02:00
|
|
|
case trySnapError:
|
2020-03-24 16:01:31 -05:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
2020-08-24 11:12:08 -05:00
|
|
|
|
|
|
|
|
var errTrySnapFallback = errors.New("fallback to original snap")
|