Skip to content

Please provide informations on error handling #198

@loeffel-io

Description

@loeffel-io

I can't find any informations about error handling, for instance i want to check for write_failed_due_to_invalid_input from https://github.com/openfga/go-sdk/blob/v0.7.1/docs/ErrorCode.md

Please provide an example

Current try:

	if _, err = service.fgaClient.
		Write(ctx).
		Body(openfgaclient.ClientWriteRequest{
			Writes:  writes,
			Deletes: deletes,
		}).
		Execute(); err != nil {
		var fgaErr *openfga.FgaApiError
		if errors.As(err, &fgaErr) {
			switch fgaErr.ResponseCode() {
			case string(openfga.ERRORCODE_WRITE_FAILED_DUE_TO_INVALID_INPUT):
				return nil, service.statusError.InvalidArgumentError(fgaErr.Error()).Err()
			}
		}

		statusErr := service.statusError.InternalError()
		service.logger.Error(fmt.Sprintf("openfga client write: %s", err), logging.ExtractFields(ctx)...)
		return nil, statusErr.Err()
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions