Skip to content

Allow dnapi consumers to access detailed errors #32

@jasikpark

Description

@jasikpark

Currently we construct an APIError when we get a validation or 404 error from the api, joining all of the error messages before returning them in an APIError { e string ReqID string } that implements the Error interface from go std lib.

It'd be useful in DNClient Desktop to be able to access an APIErrors property or something similar, to be able to go through each individual api error returned, and match on the error code and path when supplying nicer task-specific errors to users.

Simplest might be allowing the APIError struct to contain a list of APIErrors as an extra property.

// - package dnapi
// APIError wraps an error and contains the RequestID from the X-Request-ID
// header of an API response. ReqID defaults to empty string  if the header is
// not in the response.
type APIError struct {
	e     error
	ReqID string
+ APIErrors APIErrors
}

to contain

// - package message
// APIError represents a single error returned in an API error response.
type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Path    string `json:"path"` // may or may not be present
}

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