githubFailureCause function
Renders error as the TYPE-LED, bounded cause every GitHub failure in this
package ends with.
Type FIRST and cause LAST because the reasons this renders into are passed through tail-keeping truncators: rendering the raw error first meant the cut kept whatever an SDK error had embedded — for an encoding failure, the whole serialized request — and dropped the exception type and message.
The cause is error.toString() and deliberately NOT Error.safeToString,
which returns the DEFAULT Object.toString for anything that is not a
num, bool, String or null: every exception this renders would collapse
to Instance of 'StateError', discarding the message that is the whole
payload — and making the cap meaningless.
Implementation
String githubFailureCause(Object error) {
final rendered = error.toString();
final cause = rendered.length <= kMaxGitHubCauseChars
? rendered
: '${rendered.substring(0, kMaxGitHubCauseChars)}…';
return 'Cause (${error.runtimeType}): $cause';
}