Refactored the error callbacks

master
Elis Axelsson 9 years ago
parent f161620302
commit 30e78d6fe1
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 12
      tests/test-webpaste-provider-creation.el
  2. 16
      webpaste.el

@ -19,9 +19,9 @@
:success-lambda (lambda () (cl-function
(lambda (&key data &allow-other-keys)
(setq used-lambda "success"))))
:error-lambda (cl-function
(lambda (&key error-thrown &allow-other-keys)
(setq used-lambda "error")))))
:error-lambda (lambda (&rest rest) (cl-function
(lambda (&key error-thrown &allow-other-keys)
(setq used-lambda "error"))))))
(setq working-provider
(webpaste-provider
@ -31,9 +31,9 @@
:success-lambda (lambda () (cl-function
(lambda (&key data &allow-other-keys)
(setq used-lambda "success"))))
:error-lambda (cl-function
(lambda (&key error-thrown &allow-other-keys)
(setq used-lambda "error"))))))
:error-lambda (lambda (&rest rest) (cl-function
(lambda (&key error-thrown &allow-other-keys)
(setq used-lambda "error")))))))
(it

@ -100,17 +100,17 @@ precalculated, and also available both for pre and post request access.")
;;; Predefined error lambda for providers
(defvar webpaste/providers-error-lambda
(cl-defun webpaste/providers-error-lambda (&key text)
"Predefined error callback for providers that always does failover."
(cl-function (lambda (&key error-thrown &allow-other-keys)
(message "Got error: %S" error-thrown)
(webpaste-paste-text text)))
"Predefined error callback for providers that always does failover.")
(webpaste-paste-text text))))
(defvar webpaste/providers-error-lambda-no-failover
(cl-defun webpaste/providers-error-lambda-no-failover (&key text)
"Predefined error callback for providers that shouldn't do failover."
(cl-function (lambda (&key error-thrown &allow-other-keys)
(message "Got error: %S" error-thrown)))
"Predefined error callback for providers that shouldn't do failover.")
(message "Got error: %S" error-thrown))))
;;; Predefined success lambdas for providers
@ -183,7 +183,7 @@ precalculated, and also available both for pre and post request access.")
(parser 'buffer-string)
(lang-overrides '())
(lang-uri-separator nil)
(error-lambda webpaste/providers-error-lambda)
(error-lambda 'webpaste/providers-error-lambda)
(post-field-lambda webpaste/providers-default-post-field-lambda)
(sync nil))
"Function to create the lambda function for a provider.
@ -266,7 +266,7 @@ Optional params:
:parser parser
:success (funcall success-lambda)
:sync sync
:error error-lambda))))
:error (funcall error-lambda :text text)))))

Loading…
Cancel
Save