2020-04-01 09:55:42 -05:00
|
|
|
/*
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-09-19 16:49:55 +03:00
|
|
|
package redfish
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-03-09 22:00:10 +00:00
|
|
|
|
2019-12-01 14:14:09 +04:00
|
|
|
aerror "opendev.org/airship/airshipctl/pkg/errors"
|
2019-09-19 16:49:55 +03:00
|
|
|
)
|
|
|
|
|
2020-03-17 15:35:02 +00:00
|
|
|
// ErrRedfishClient describes an error encountered by the go-redfish client.
|
|
|
|
type ErrRedfishClient struct {
|
2019-09-19 16:49:55 +03:00
|
|
|
aerror.AirshipError
|
2020-03-17 15:35:02 +00:00
|
|
|
Message string
|
2019-09-19 16:49:55 +03:00
|
|
|
}
|
|
|
|
|
2020-03-17 15:35:02 +00:00
|
|
|
func (e ErrRedfishClient) Error() string {
|
|
|
|
return fmt.Sprintf("redfish client encountered an error: %s", e.Message)
|
2019-09-19 16:49:55 +03:00
|
|
|
}
|
|
|
|
|
2020-03-17 15:35:02 +00:00
|
|
|
// ErrRedfishMissingConfig describes an error encountered due to a missing configuration option.
|
2020-02-11 11:54:18 -05:00
|
|
|
type ErrRedfishMissingConfig struct {
|
|
|
|
What string
|
2019-09-19 16:49:55 +03:00
|
|
|
}
|
|
|
|
|
2020-02-11 11:54:18 -05:00
|
|
|
func (e ErrRedfishMissingConfig) Error() string {
|
|
|
|
return "missing configuration: " + e.What
|
2019-09-19 16:49:55 +03:00
|
|
|
}
|
|
|
|
|
2020-03-16 14:14:04 +04:00
|
|
|
// ErrOperationRetriesExceeded raised if number of operation retries exceeded
|
|
|
|
type ErrOperationRetriesExceeded struct {
|
2020-04-16 22:53:14 +00:00
|
|
|
What string
|
|
|
|
Retries int
|
2020-03-16 14:14:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrOperationRetriesExceeded) Error() string {
|
2020-04-16 22:53:14 +00:00
|
|
|
return fmt.Sprintf("operation %s failed. Maximum retries (%d) exceeded", e.What, e.Retries)
|
2020-03-16 14:14:04 +04:00
|
|
|
}
|