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

[Feature request]: Silence "[error] request--callback: peculiar error" when aborting without setting custom variables #226

Open
daanturo opened this issue May 16, 2024 · 2 comments

Comments

@daanturo
Copy link

Currently when using request-abort, an error will be echoed:

[error] request--callback: peculiar error

This cannot be disabled without setting request-message-level (If I understand correctly).

Reproduce

(progn
  (let* ((req
          (request
           "http://httpbin.org/post"
           :type "POST"
           :data '(("key" . "value"))
           :error 'ignore
           :parser 'json-read
           :success (cl-function 'ignore))))
    ;; I tried let-binding here, but callbacks are asynchronous so they aren't
    ;; affected
    (dlet ((request-message-level -1))
      (request-abort req))
    ""))

Observed

[error] request--callback: peculiar error appears in the echo area and *Message*.

Expected

Silent

Is it possible to abort the running request, without informing the user? My package depends of request, so setq-ing an user option without their consent is not polite. Maybe adding more optional arguments to request-abort to silence errors?

@dickmao
Copy link
Collaborator

dickmao commented May 16, 2024

Here's one conspicuously bad way of doing it:

(request-abort
 (let ((req (request "http://httpbin.org/post"
	      :type "POST"
	      :data '(("key" . "value"))
	      :error (lambda (&rest _args) (message "got here"))
	      :parser #'json-read
	      :success #'ignore)))
   (prog1 req
     (add-function
      :around
      (process-sentinel (get-buffer-process
			 (request-response--buffer req)))
      (lambda (f &rest args)
	(let ((request-message-level -1))
	  (apply f args)))))))

@daanturo
Copy link
Author

Here's one conspicuously bad way of doing it:

(request-abort
 (let ((req (request "http://httpbin.org/post"
	      :type "POST"
	      :data '(("key" . "value"))
	      :error (lambda (&rest _args) (message "got here"))
	      :parser #'json-read
	      :success #'ignore)))
   (prog1 req
     (add-function
      :around
      (process-sentinel (get-buffer-process
			 (request-response--buffer req)))
      (lambda (f &rest args)
	(let ((request-message-level -1))
	  (apply f args)))))))

Thank you that works for me.

But I really hope that there would be an official support, like 506500e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants