{"record":{"id":"56f03e1fa40b44ce","repo":"NickeManarin/ScreenToGif","slug":"history-message","errorCode":null,"errorMessage":"history.Message","messagePattern":"history\\.Message","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ScreenToGif/Util/EncodingManager.cs","lineNumber":1172,"sourceCode":"                {\n                    //Get selected preset.\n                    var presetType = preset.Extension == \".zip\" ? ExportFormats.Zip : preset.Type;\n                    var uploadPreset = UserSettings.All.UploadPresets.OfType<UploadPreset>().FirstOrDefault(f => (f.AllowedTypes.Count == 0 || f.AllowedTypes.Contains(presetType)) && f.Title == preset.UploadService);\n\n                    if (uploadPreset == null)\n                        throw new Exception($\"Missing upload preset called {preset.UploadService}\");\n\n                    //TODO: Limit upload by imposed service limits.\n\n                    //Try uploading to the selected service.\n                    var cloud = CloudFactory.CreateCloud(uploadPreset.Type);\n                    var history = await cloud.UploadFileAsync(uploadPreset, preset.FullPath, CancellationToken.None);\n\n                    uploadPreset.History.Add(history);\n                    UserSettings.Save();\n\n                    if (history.Result != 200)\n                        throw new Exception(history.Message);\n\n                    SetUpload(id, true, history.GetLink(uploadPreset), history.DeletionLink);\n                }\n                catch (Exception e)\n                {\n                    LogWriter.Log(e, \"It was not possible to upload.\");\n                    SetUpload(id, false, null, null, e);\n                }\n                finally\n                {\n                    Update(id, 2, watch.Elapsed);\n                    watch.Restart();\n                }\n            }\n\n            #endregion\n\n            #region Copy to clipboard","sourceCodeStart":1154,"sourceCodeEnd":1190,"githubUrl":"https://github.com/NickeManarin/ScreenToGif/blob/a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd/ScreenToGif/Util/EncodingManager.cs#L1154-L1190","documentation":"After cloud.UploadFileAsync returns a History object, EncodingManager checks history.Result. If it is not 200, it throws new Exception(history.Message) — the message the cloud uploader set on its History. This is the non-throwing failure path of uploaders that report failure via the Result code rather than an exception.","triggerScenarios":"UploadFileAsync returns a populated History with Result != 200 (e.g. 4xx/5xx captured inside the uploader without throwing, or a service-specific non-success code) and a non-null Message.","commonSituations":"Cloud provider returned an HTTP error that the uploader swallowed into the History object; partial upload; service-side validation rejection; rate-limit body returned with a non-200 status that the uploader chose not to throw on.","solutions":["Inspect history.Message — it usually contains the provider's error text (often mirroring error 22/24 for Imgur/Yandex).","Re-run the upload after addressing the cause described in history.Message.","Check the History entry appended to uploadPreset.History for the persisted error context.","If the uploader should have thrown, harden it to throw UploadException on non-200 instead of returning a failure History."],"exampleFix":"// before\nif (history.Result != 200)\n    throw new Exception(history.Message);\n\n// after\nif (history.Result != 200)\n    throw new UploadException($\"Upload to {uploadPreset.Title} failed ({history.Result}): {history.Message}\");","handlingStrategy":"try-catch","validationCode":"// Uploader implementers: throw UploadException on non-200 instead of returning a History\nif (response.StatusCode != HttpStatusCode.OK)\n    throw new UploadException($\"HTTP {(int)response.StatusCode}\");","typeGuard":"// n/a","tryCatchPattern":"var history = await cloud.UploadFileAsync(uploadPreset, path, token);\nif (history.Result != 200)\n    throw new UploadException($\"Upload failed ({history.Result}): {history.Message}\");","preventionTips":["Standardize uploaders to throw on non-200 rather than returning failure Histories.","Inspect history.Message text in the catch to decide between retry (transient) and user action (auth/quota).","Append history to uploadPreset.History before evaluating Result so failures are auditable."],"tags":["upload","cloud-upload","encoding","api-error"],"backgroundTag":null,"analyzedSha":"a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd","analyzedAt":"2026-08-13T11:12:06.147Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}