API Fetch Utility could provide more information on error #486
marcustyphoon
started this conversation in
Tech Office
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am like 4 layers deep into this one haha.
I was in the middle of writing a somewhat lengthy discussion post about ways to improve error messages from injected functions...
The discussion post draft
...and then I did more testing and realized that most of it only applies to errors in which the injection returns a rejected promise with useful information rather than throwing, i.e. just apiFetch, basically. So, starting over:
The current error handling in the apiFetch injection passes through a rejected promise, which results in essentially no stack trace data being logged if there is an error:
Ultimately you can tell that this is a 404, what URL 404'd, and that this is XKit Rewritten related, so ultimately perhaps that's enough. But this code shows that more info can be added, at least in Chromium:
I tried some things with manipulating the stack property on the error objects, which kind of works, but ultimately it just seemed simpler to just
console.warnconsole.error from a location in which the rich stack trace that is automatically included. In Chrome, this identifies the whole stack trace including the function that injected the script element; unfortunately, it doesn't in Firefox:Anyways, this also prints the status data provided by Tumblr's apiFetch. Maybe this would be useful if a user encountered a problem and was providing the console output?
Beta Was this translation helpful? Give feedback.
All reactions