mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 12:21:12 +00:00
Generate error enum types (#161)
* Generate error enum types * Remove unnecessary newline * Catch errors not covered by LemmyErrorType --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
parent
2b757d39ec
commit
b5355233fd
4 changed files with 149 additions and 1 deletions
|
@ -12,6 +12,7 @@ cp db_schema/bindings/* ../../lemmy-js-client/src/types/
|
|||
cp db_views/bindings/* ../../lemmy-js-client/src/types/
|
||||
cp db_views_actor/bindings/* ../../lemmy-js-client/src/types/
|
||||
cp db_views_moderator/bindings/* ../../lemmy-js-client/src/types/
|
||||
cp utils/bindings/* ../../lemmy-js-client/src/types/
|
||||
|
||||
popd
|
||||
|
||||
|
|
|
@ -1329,7 +1329,14 @@ export class LemmyHttp {
|
|||
body: JSON.stringify(form),
|
||||
});
|
||||
}
|
||||
const json = await response.json();
|
||||
|
||||
let json: any | undefined = undefined;
|
||||
|
||||
try {
|
||||
json = await response.json();
|
||||
} catch (error) {
|
||||
throw response.statusText;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw json["error"] ?? response.statusText;
|
||||
|
|
|
@ -121,6 +121,7 @@ export { InstanceId } from "./types/InstanceId";
|
|||
export { Language } from "./types/Language";
|
||||
export { LanguageId } from "./types/LanguageId";
|
||||
export { LeaveAdmin } from "./types/LeaveAdmin";
|
||||
export { LemmyErrorType } from "./types/LemmyErrorType";
|
||||
export { ListCommentReports } from "./types/ListCommentReports";
|
||||
export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
|
||||
export { ListCommunities } from "./types/ListCommunities";
|
||||
|
|
139
src/types/LemmyErrorType.ts
Normal file
139
src/types/LemmyErrorType.ts
Normal file
|
@ -0,0 +1,139 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type LemmyErrorType =
|
||||
| { error_type: "ReportReasonRequired" }
|
||||
| { error_type: "ReportTooLong" }
|
||||
| { error_type: "NotAModerator" }
|
||||
| { error_type: "NotAnAdmin" }
|
||||
| { error_type: "CannotBlockYourself" }
|
||||
| { error_type: "CannotBlockAdmin" }
|
||||
| { error_type: "CouldNotUpdateUser" }
|
||||
| { error_type: "PasswordsDoNotMatch" }
|
||||
| { error_type: "PasswordIncorrect" }
|
||||
| { error_type: "EmailNotVerified" }
|
||||
| { error_type: "EmailRequired" }
|
||||
| { error_type: "CouldNotUpdateComment" }
|
||||
| { error_type: "CouldNotUpdatePrivateMessage" }
|
||||
| { error_type: "CannotLeaveAdmin" }
|
||||
| { error_type: "NoLinesInHtml" }
|
||||
| { error_type: "SiteMetadataPageIsNotDoctypeHtml" }
|
||||
| { error_type: "PictrsResponseError"; message: string }
|
||||
| { error_type: "PictrsPurgeResponseError"; message: string }
|
||||
| { error_type: "ImageUrlMissingPathSegments" }
|
||||
| { error_type: "ImageUrlMissingLastPathSegment" }
|
||||
| { error_type: "PictrsApiKeyNotProvided" }
|
||||
| { error_type: "NoContentTypeHeader" }
|
||||
| { error_type: "NotAnImageType" }
|
||||
| { error_type: "NotAModOrAdmin" }
|
||||
| { error_type: "NoAdmins" }
|
||||
| { error_type: "NotTopAdmin" }
|
||||
| { error_type: "NotTopMod" }
|
||||
| { error_type: "NotLoggedIn" }
|
||||
| { error_type: "SiteBan" }
|
||||
| { error_type: "Deleted" }
|
||||
| { error_type: "BannedFromCommunity" }
|
||||
| { error_type: "CouldNotFindCommunity" }
|
||||
| { error_type: "PersonIsBlocked" }
|
||||
| { error_type: "DownvotesAreDisabled" }
|
||||
| { error_type: "InstanceIsPrivate" }
|
||||
| { error_type: "InvalidPassword" }
|
||||
| { error_type: "SiteDescriptionLengthOverflow" }
|
||||
| { error_type: "HoneypotFailed" }
|
||||
| { error_type: "RegistrationApplicationIsPending" }
|
||||
| { error_type: "PrivateInstanceCannotHaveFederationEnabled" }
|
||||
| { error_type: "Locked" }
|
||||
| { error_type: "CouldNotCreateComment" }
|
||||
| { error_type: "MaxCommentDepthReached" }
|
||||
| { error_type: "EditCommentNotAllowed" }
|
||||
| { error_type: "OnlyAdminsCanCreateCommunities" }
|
||||
| { error_type: "CommunityAlreadyExists" }
|
||||
| { error_type: "LanguageNotAllowed" }
|
||||
| { error_type: "OnlyModsCanPostInCommunity" }
|
||||
| { error_type: "CouldNotUpdatePost" }
|
||||
| { error_type: "EditPostNotAllowed" }
|
||||
| { error_type: "CouldNotFindPost" }
|
||||
| { error_type: "EditPrivateMessageNotAllowed" }
|
||||
| { error_type: "SiteAlreadyExists" }
|
||||
| { error_type: "ApplicationQuestionRequired" }
|
||||
| { error_type: "InvalidDefaultPostListingType" }
|
||||
| { error_type: "RegistrationClosed" }
|
||||
| { error_type: "RegistrationApplicationAnswerRequired" }
|
||||
| { error_type: "EmailAlreadyExists" }
|
||||
| { error_type: "FederationError"; message: string }
|
||||
| { error_type: "FederationForbiddenByStrictAllowList" }
|
||||
| { error_type: "PersonIsBannedFromCommunity" }
|
||||
| { error_type: "ObjectIsNotPublic" }
|
||||
| { error_type: "InvalidCommunity" }
|
||||
| { error_type: "CannotCreatePostOrCommentInDeletedOrRemovedCommunity" }
|
||||
| { error_type: "CannotReceivePage" }
|
||||
| { error_type: "NewPostCannotBeLocked" }
|
||||
| { error_type: "OnlyLocalAdminCanRemoveCommunity" }
|
||||
| { error_type: "OnlyLocalAdminCanRestoreCommunity" }
|
||||
| { error_type: "NoIdGiven" }
|
||||
| { error_type: "CouldNotFindUsernameOrEmail" }
|
||||
| { error_type: "InvalidQuery" }
|
||||
| { error_type: "ObjectNotLocal" }
|
||||
| { error_type: "PostIsLocked" }
|
||||
| { error_type: "PersonIsBannedFromSite" }
|
||||
| { error_type: "InvalidVoteValue" }
|
||||
| { error_type: "PageDoesNotSpecifyCreator" }
|
||||
| { error_type: "PageDoesNotSpecifyGroup" }
|
||||
| { error_type: "NoCommunityFoundInCC" }
|
||||
| { error_type: "NoEmailSetup" }
|
||||
| { error_type: "EmailSmtpServerNeedsAPort" }
|
||||
| { error_type: "MissingAnEmail" }
|
||||
| { error_type: "RateLimitError" }
|
||||
| { error_type: "InvalidName" }
|
||||
| { error_type: "InvalidDisplayName" }
|
||||
| { error_type: "InvalidMatrixId" }
|
||||
| { error_type: "InvalidPostTitle" }
|
||||
| { error_type: "InvalidBodyField" }
|
||||
| { error_type: "BioLengthOverflow" }
|
||||
| { error_type: "MissingTotpToken" }
|
||||
| { error_type: "IncorrectTotpToken" }
|
||||
| { error_type: "CouldNotParseTotpSecret" }
|
||||
| { error_type: "CouldNotLikeComment" }
|
||||
| { error_type: "CouldNotSaveComment" }
|
||||
| { error_type: "CouldNotCreateReport" }
|
||||
| { error_type: "CouldNotResolveReport" }
|
||||
| { error_type: "CommunityModeratorAlreadyExists" }
|
||||
| { error_type: "CommunityUserIsAlreadyBanned" }
|
||||
| { error_type: "CommunityBlockAlreadyExists" }
|
||||
| { error_type: "CommunityFollowerAlreadyExists" }
|
||||
| { error_type: "CouldNotUpdateCommunityHiddenStatus" }
|
||||
| { error_type: "PersonBlockAlreadyExists" }
|
||||
| { error_type: "UserAlreadyExists" }
|
||||
| { error_type: "TokenNotFound" }
|
||||
| { error_type: "CouldNotLikePost" }
|
||||
| { error_type: "CouldNotSavePost" }
|
||||
| { error_type: "CouldNotMarkPostAsRead" }
|
||||
| { error_type: "CouldNotUpdateCommunity" }
|
||||
| { error_type: "CouldNotUpdateReplies" }
|
||||
| { error_type: "CouldNotUpdatePersonMentions" }
|
||||
| { error_type: "PostTitleTooLong" }
|
||||
| { error_type: "CouldNotCreatePost" }
|
||||
| { error_type: "CouldNotCreatePrivateMessage" }
|
||||
| { error_type: "CouldNotUpdatePrivate" }
|
||||
| { error_type: "SystemErrLogin" }
|
||||
| { error_type: "CouldNotSetAllRegistrationsAccepted" }
|
||||
| { error_type: "CouldNotSetAllEmailVerified" }
|
||||
| { error_type: "Banned" }
|
||||
| { error_type: "CouldNotGetComments" }
|
||||
| { error_type: "CouldNotGetPosts" }
|
||||
| { error_type: "InvalidUrl" }
|
||||
| { error_type: "EmailSendFailed" }
|
||||
| { error_type: "Slurs" }
|
||||
| { error_type: "CouldNotGenerateTotp" }
|
||||
| { error_type: "CouldNotFindObject" }
|
||||
| { error_type: "RegistrationDenied"; message: string }
|
||||
| { error_type: "FederationDisabled" }
|
||||
| { error_type: "DomainBlocked" }
|
||||
| { error_type: "DomainNotInAllowList" }
|
||||
| { error_type: "FederationDisabledByStrictAllowList" }
|
||||
| { error_type: "SiteNameRequired" }
|
||||
| { error_type: "SiteNameLengthOverflow" }
|
||||
| { error_type: "PermissiveRegex" }
|
||||
| { error_type: "InvalidRegex" }
|
||||
| { error_type: "CaptchaIncorrect" }
|
||||
| { error_type: "PasswordResetLimitReached" }
|
||||
| { error_type: "CouldNotCreateAudioCaptcha" };
|
Loading…
Reference in a new issue