Skip to content
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

notify error should invoke a separate client error handler #418

Open
plastikfan opened this issue Jan 18, 2024 · 0 comments
Open

notify error should invoke a separate client error handler #418

plastikfan opened this issue Jan 18, 2024 · 0 comments
Assignees
Labels
feature New feature or request

Comments

@plastikfan
Copy link
Contributor

consider this:

func (a *navigationAgent) notify(params *agentNotifyParams) (SkipTraversal, error) {
	skip := SkipNoneTraversalEn

	if params.readErr != nil {
		if a.doInvoke.Get() {
			clone := params.current.clone()
			clone.Error = i18n.NewThirdPartyErr(params.readErr)

			// Second call, to report ReadDir error
			//
			if le := params.frame.proxy(clone, nil); le != nil {
				if errors.Is(params.readErr, fs.SkipAll) && (clone.IsDirectory()) {
					params.readErr = nil
				}

				return SkipAllTraversalEn, i18n.NewThirdPartyErr(params.readErr)
			}
		} else {
			return SkipAllTraversalEn, i18n.NewThirdPartyErr(params.readErr)
		}
	}

	return skip, nil
}

If an error occurs during the navigation process, the navigator will invoke the client callback with the item on the traverse item being set. Perhaps this is not the best way to go, becuase the client has to know that they are being invoked for a second time for the same traversal item but for an error. It would probably be better for the client to be able to specify an error callback specifically for the purpose of error handling, that way the prmary client callback can be kept clean and not have to be concerned about error handling.

@plastikfan plastikfan added the feature New feature or request label Jan 18, 2024
@plastikfan plastikfan self-assigned this Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant