You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently salesforce.core/request doesn't handle properly the case when SFDC API returns error.
There is try/catch around clj-http.client/request but then parse-limit-info crashes with NullPointerException due to absence [:headers "sforce-limit-info"] in the resp.
Even when pass through the parse-limit-info, the salesforce.core/request returns nil instead of SFDC error message since exception's :body is already extracted.
Please consider the diff:
--- a/src/salesforce/core.clj
+++ b/src/salesforce/core.clj
@@ -1,6 +1,5 @@
(ns salesforce.core
(:require
- [clojure.string :as str]
[cheshire.core :as json]
[clj-http.client :as http]
[clojure.string :as str]
@@ -71,10 +70,10 @@
{:method method
:url full-url
:headers {"Authorization" (str "Bearer " (:access_token token))}}))
- (catch Exception e (:body (ex-data e))))]
- (-> (get-in resp [:headers "sforce-limit-info"]) ;; Record limit info in atom
- (parse-limit-info)
- ((partial reset! limit-info)))
+ (catch Exception e (ex-data e)))]
+ (some-> (get-in resp [:headers "sforce-limit-info"]) ;; Record limit info in atom
+ (parse-limit-info)
+ ((partial reset! limit-info)))
(-> resp
:body
(json/decode true))))
BEFORE
=> (sf/so->objects auth)
Execution error (NullPointerException) at (REPL:1).
null
AFTER
=> (sf/so->objects auth)
({:message "The REST API is not enabled for this Organization.", :errorCode "API_DISABLED_FOR_ORG"})
The text was updated successfully, but these errors were encountered:
kubrack
added a commit
to kubrack/salesforce
that referenced
this issue
Jun 29, 2023
Currently
salesforce.core/request
doesn't handle properly the case when SFDC API returns error.There is
try/catch
around clj-http.client/request but thenparse-limit-info
crashes withNullPointerException
due to absence[:headers "sforce-limit-info"]
in theresp
.Even when pass through the
parse-limit-info
, thesalesforce.core/request
returnsnil
instead of SFDC error message since exception's:body
is already extracted.Please consider the diff:
BEFORE
AFTER
The text was updated successfully, but these errors were encountered: