Skip to content

[DEV] Refactor GetXXX(...) call in StorageProvider to explicit handle entities not existing #39

@cjh1

Description

@cjh1

Short Description
Currently calling logic relies on errors contain "does not exist" to indicate that an entity doesn't exist. We should change this so it more explicit by returning a pointer, so it can be nil to indicate the entity not existing.

Definition of Done
The signatures are updated and the calling logic of the form strings.Contains(err.Error(), "does not exist") is replaced with entity == nil.

Additional context

internal/domain/power-cap.go:279:               if strings.Contains(err.Error(), "does not exist") {
internal/domain/power-status.go:1022:           if !strings.Contains(err.Error(), "does not exist") {
internal/domain/transitions.go:121:             if strings.Contains(err.Error(), "does not exist") {
internal/domain/transitions.go:193:                     if strings.Contains(err.Error(), "does not exist") {
internal/domain/transitions.go:925:                                             if !strings.Contains(err.Error(), "does not exist") {
internal/domain/transitions.go:1029:                    if !strings.Contains(err.Error(), "does not exist") {
internal/domain/transitions.go:1066:            if !strings.Contains(err.Error(), "does not exist") {
internal/domain/transitions.go:1117:                                    if strings.Contains(err.Error(), "does not exist") {
internal/domain/transitions.go:1182:     

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions