Skip to content

Add "Resource Not Found" errors in opslevel-go #496

@rocktavious

Description

@rocktavious

Customer calling code looks like this

	service, err := client.GetService(serviceIdentifier)
	if err != nil {
		resp.Diagnostics.AddError("opslevel client error", fmt.Sprintf("Unable to read service, got error: %s", err))
		return
	}

But there are cases where service == nil and service.Id == nil which this doesn't handle which means it passes the client code error handling and they have to do this

	service, err := client.GetService(serviceIdentifier)
	if err != nil || service == nil || service.Id == nil {
		resp.Diagnostics.AddError("opslevel client error", fmt.Sprintf("Unable to read service, got error: %s", err))
		return
	}

We should fix this by adding a custom "Resource Not Found" error that we emit when service == nil || service.Id == nil but it should be done in the client.GetService function.

Then wash, rinse, repeat for all "get" functions in the opslevel-go client.

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