Charger: add expection handling for status E (#8460)
This commit is contained in:
parent
1ec690c6a8
commit
d4cfa052bd
3 changed files with 11 additions and 2 deletions
|
|
@ -54,6 +54,15 @@ func ChargeStatusString(s string) (ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// ChargeStatusStringWithMapping converts a string to ChargeStatus. In case of error, mapping is applied.
|
||||
func ChargeStatusStringWithMapping(s string, m map[ChargeStatus]ChargeStatus) (ChargeStatus, error) {
|
||||
status, err := ChargeStatusString(s)
|
||||
if mappedStatus, ok := m[status]; ok && err != nil {
|
||||
return mappedStatus, nil
|
||||
}
|
||||
return status, err
|
||||
}
|
||||
|
||||
// String implements Stringer
|
||||
func (c ChargeStatus) String() string {
|
||||
return string(c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue