Skip to content

Commit

Permalink
fix(api): change error property to message
Browse files Browse the repository at this point in the history
  • Loading branch information
Ro0t-set committed May 24, 2024
1 parent 47c7d6e commit 27e7f71
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 83 deletions.
6 changes: 3 additions & 3 deletions frontend-service/src/main/vue/api/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ErrorResponse } from "./response";

export class InternalServerError extends ErrorResponse {
statusCode = 500;
error = "Internal Server Error" as const;
message = "Internal Server Error" as const;
errorMessage: unknown;
constructor(e: unknown = "") {
super();
Expand All @@ -12,7 +12,7 @@ export class InternalServerError extends ErrorResponse {

export class BadRequest extends ErrorResponse {
statusCode = 400;
error = "Bad Request" as const;
message = "Bad Request" as const;
missingParams: string[];
missingBody: string[];
missingQuery?: string[];
Expand All @@ -26,5 +26,5 @@ export class BadRequest extends ErrorResponse {

export class JwtTokenMissingOrInvalid extends ErrorResponse {
statusCode = 401;
error = "JWT Token Missing or Invalid" as const;
message = "JWT Token Missing or Invalid" as const;
}
12 changes: 6 additions & 6 deletions frontend-service/src/main/vue/api/messages/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ export module GetChannelMessagesApi {
export module Errors {
export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
message = "Channel not found" as const;
}
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}

export type Type = ChannelNotFound | ServerNotFound | UserNotAuthorized;
Expand Down Expand Up @@ -91,15 +91,15 @@ export module SendMessageInChannelApi {
export module Errors {
export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
message = "Channel not found" as const;
}
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}
export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}
export type Type = ChannelNotFound | ServerNotFound | UserNotAuthorized;
}
Expand Down
6 changes: 3 additions & 3 deletions frontend-service/src/main/vue/api/messages/direct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export module GetDirectMessagesApi {
export module Errors {
export class DirectNotFound extends ErrorResponse {
statusCode = 404;
error = "Direct not found" as const;
message = "Direct not found" as const;
}
export type Type = DirectNotFound;
}
Expand Down Expand Up @@ -78,11 +78,11 @@ export module SendDirectMessageApi {
export module Errors {
export class DirectNotFound extends ErrorResponse {
statusCode = 404;
error = "Direct not found" as const;
message = "Direct not found" as const;
}
export class CannotSendDirectMessageToYourself extends ErrorResponse {
statusCode = 400;
error = "Cannot send direct message to yourself" as const;
message = "Cannot send direct message to yourself" as const;
}
export type Type = DirectNotFound | CannotSendDirectMessageToYourself;
}
Expand Down
32 changes: 16 additions & 16 deletions frontend-service/src/main/vue/api/piperchat/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export module GetChannelsApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}

export type Type = ServerNotFound | UserNotAuthorized;
Expand Down Expand Up @@ -88,17 +88,17 @@ export module GetChannelByIdApi {
export module Errors {
export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
message = "Channel not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}

export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}

export type Type = ChannelNotFound | UserNotAuthorized | ServerNotFound;
Expand Down Expand Up @@ -158,22 +158,22 @@ export module CreateChannelApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}

export class ChannelAlreadyExists extends ErrorResponse {
statusCode = 409;
error = "Channel already exists" as const;
message = "Channel already exists" as const;
}

export class InvalidChannelType extends ErrorResponse {
statusCode = 400;
error = "Invalid channel type" as const;
message = "Invalid channel type" as const;
}

export type Type =
Expand Down Expand Up @@ -218,22 +218,22 @@ export module UpdateChannelApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}

export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
message = "Channel not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}

export class ChannelAlreadyExists extends ErrorResponse {
statusCode = 409;
error = "Channel already exists" as const;
message = "Channel already exists" as const;
}

export type Type =
Expand Down Expand Up @@ -272,17 +272,17 @@ export module DeleteChannelApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}

export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
message = "Channel not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}

export type Type = ServerNotFound | ChannelNotFound | UserNotAuthorized;
Expand Down
38 changes: 19 additions & 19 deletions frontend-service/src/main/vue/api/piperchat/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export module KickUserFromServerApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server or user not found" as const;
message = "Server or user not found" as const;
}
export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}
export class OwnerCannotLeave extends ErrorResponse {
statusCode = 405;
error = "Owner cannot leave the server" as const;
message = "Owner cannot leave the server" as const;
}
export type Type = ServerNotFound | UserNotAuthorized | OwnerCannotLeave;
}
Expand Down Expand Up @@ -68,11 +68,11 @@ export module GetServerParticipantsApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}
export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}
export type Type = ServerNotFound | UserNotAuthorized;
}
Expand Down Expand Up @@ -103,11 +103,11 @@ export module JoinServerApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}
export class UserAlreadyJoined extends ErrorResponse {
statusCode = 403;
error = "User already joined" as const;
message = "User already joined" as const;
}
export type Type = ServerNotFound | UserAlreadyJoined;
}
Expand Down Expand Up @@ -138,15 +138,15 @@ export module LeaveServerApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}
export class UserNotInServer extends ErrorResponse {
statusCode = 403;
error = "User not in server" as const;
message = "User not in server" as const;
}
export class OwnerCannotLeave extends ErrorResponse {
statusCode = 422;
error = "Owner cannot leave the server" as const;
message = "Owner cannot leave the server" as const;
}
export type Type = ServerNotFound | UserNotInServer | OwnerCannotLeave;
}
Expand Down Expand Up @@ -193,11 +193,11 @@ export module GetServerApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}
export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}
export type Type = ServerNotFound | UserNotAuthorized;
}
Expand Down Expand Up @@ -234,15 +234,15 @@ export module UpdateServerApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}
export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}
export class NameOrDescriptionRequired extends ErrorResponse {
statusCode = 422;
error = "Name or description required" as const;
message = "Name or description required" as const;
}
export type Type = ServerNotFound | UserNotAuthorized;
}
Expand Down Expand Up @@ -273,11 +273,11 @@ export module DeleteServerApi {
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
message = "Server not found" as const;
}
export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
message = "User not authorized" as const;
}
export type Type = ServerNotFound | UserNotAuthorized;
}
Expand Down Expand Up @@ -322,7 +322,7 @@ export module GetServersApi {
export module Errors {
export class UserNotFound extends ErrorResponse {
statusCode = 404;
error = "User not found" as const;
message = "User not found" as const;
}
export type Type = UserNotFound;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ export module CreateServerApi {
export module Errors {
export class NameOrDescriptionRequired extends ErrorResponse {
statusCode = 422;
error = "Name or description required" as const;
message = "Name or description required" as const;
}
export type Type = NameOrDescriptionRequired;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend-service/src/main/vue/api/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export abstract class Response {
}

export abstract class ErrorResponse extends Response {
abstract error: string;
abstract message: string;
}
12 changes: 6 additions & 6 deletions frontend-service/src/main/vue/api/users/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ export module RegisterApi {
export module Errors {
export class UserAlreadyExists extends ErrorResponse {
statusCode = 409;
error = "User already exists" as const;
message = "User already exists" as const;
}

export class EmailAlreadyExists extends ErrorResponse {
statusCode = 409;
error = "Email already exists" as const;
message = "Email already exists" as const;
}

export type Type = UserAlreadyExists | EmailAlreadyExists;
Expand Down Expand Up @@ -116,7 +116,7 @@ export module LoginApi {
export module Errors {
export class UsernameOrPasswordIncorrect extends ErrorResponse {
statusCode = 401;
error = "Username or password incorrect" as const;
message = "Username or password incorrect" as const;
}
export type Type = UsernameOrPasswordIncorrect;
}
Expand Down Expand Up @@ -149,7 +149,7 @@ export module LogoutApi {
export module Errors {
export class UserNotFound extends ErrorResponse {
statusCode = 404;
error = "User not found" as const;
message = "User not found" as const;
}
export type Type = UserNotFound;
}
Expand Down Expand Up @@ -185,11 +185,11 @@ export module RefreshTokenApi {
export module Errors {
export class UserNotFound extends ErrorResponse {
statusCode = 404;
error = "User not found" as const;
message = "User not found" as const;
}
export class InvalidRefreshToken extends ErrorResponse {
statusCode = 401;
error = "Refresh token is missing or invalid" as const;
message = "Refresh token is missing or invalid" as const;
}
export type Type = UserNotFound | InvalidRefreshToken;
}
Expand Down
Loading

0 comments on commit 27e7f71

Please sign in to comment.