Skip to content

Commit

Permalink
Merge pull request #1040 from WolframResearch/999-need-error-handling…
Browse files Browse the repository at this point in the history
…-in-processdocumentationsnippetresult-for-when-cloud-is-unreachable-no-status-code-returned

Bugfix: Add error handling for unreachable cloud in snippet downloading
  • Loading branch information
rhennigan authored Jan 21, 2025
2 parents 3fc3474 + 25f785e commit b8c2f66
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Chatbook/Common.wl
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ catchMine // endDefinition;
(* ::Subsection::Closed:: *)
(*throwTop*)
throwTop // beginDefinition;
throwTop[ expr_ ] /; $catching := Throw[ Unevaluated @ expr, $catchTopTag ];
throwTop[ expr_ ] := If[ TrueQ @ $catching, Throw[ Unevaluated @ expr, $catchTopTag ], expr ];
throwTop // endDefinition;

(* ::**************************************************************************************************************:: *)
Expand Down
4 changes: 3 additions & 1 deletion Source/Chatbook/PromptGenerators/RelatedDocumentation.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,9 @@ processDocumentationSnippetResult[ base_String, as_Association ] :=
processDocumentationSnippetResult[ base_String, as_, bytes_ByteArray, 200 ] :=
processDocumentationSnippetResult[ base, as, Quiet @ Developer`ReadWXFByteArray @ bytes ];

processDocumentationSnippetResult[ base_String, as_Association, bytes_, code: Except[ 200, _Integer ] ] :=
(* A 401/403 means we're missing a file in the snippet deployment or it has the wrong permissions,
so it should trigger an internal failure, otherwise just issue a generic cloud download failure. *)
processDocumentationSnippetResult[ base_String, as_Association, bytes_, code: Except[ 401|403 ] ] :=
throwFailureToChatOutput @ Failure[
"CloudDownloadError",
<|
Expand Down
2 changes: 1 addition & 1 deletion Source/Chatbook/SendChat.wl
Original file line number Diff line number Diff line change
Expand Up @@ -2594,7 +2594,7 @@ throwFailureToChatOutput[ task_, cell_CellObject, failure_ ] := (
]
);

throwFailureToChatOutput[ task_, None, failure_Failure ] := (
throwFailureToChatOutput[ task_, _, failure_Failure ] := (
Quiet @ TaskRemove @ task;
throwTop @ failure
);
Expand Down

0 comments on commit b8c2f66

Please sign in to comment.