Skip to content

Please provide informations on error handling #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
loeffel-io opened this issue Apr 24, 2025 · 0 comments
Open

Please provide informations on error handling #198

loeffel-io opened this issue Apr 24, 2025 · 0 comments

Comments

@loeffel-io
Copy link

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()
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant