Skip to content

Implement RFC7807: Problem Details for HTTP APIs #112

Description

@gerardsn

Following #3 and #9 we propose to implement RFC7807 to standardize API error handling. More specifically, define "Title", "Status", and "detail" members for each problem.

One of the current methods used is

func (a Wrapper) GetDID(ctx echo.Context, did string) error {
	d, err := did2.ParseDID(did)
	if err != nil {
		return ctx.String(http.StatusBadRequest, fmt.Sprintf("given DID could not be parsed: %s", err.Error()))
	}
       ...
}

which can be standardized using https://github.com/mschneider82/problem to something like

func (a Wrapper) GetDID(ctx echo.Context, did string) error {
	d, err := did2.ParseDID(did)
	if err != nil {
		p := problem.Of(http.StatusBadRequest)
		p.Append(problem.Title("given DID could not be parsed"))
		p.Append(problem.Detail(err.Error()))
		return p
	}
       ...
}

This will require:

Implement standard in APIs:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions