mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-28 07:24:08 +00:00
Merge remote-tracking branch 'mathium05/errorFix'
This commit is contained in:
@@ -29,10 +29,9 @@ export type ErrorContent = { code: string; message: string };
|
||||
export type ObjectErrorContent = { _errors: ErrorContent[] };
|
||||
|
||||
export function FieldErrors(fields: Record<string, { code?: string; message: string }>, errors?: ErrorObject[]) {
|
||||
const errorsObject = {} as Record<string, ObjectErrorContent>;
|
||||
|
||||
Object.entries(fields).map(([key, { message, code }]) => {
|
||||
errorsObject[key] = {
|
||||
const errorObj: ErrorList = {};
|
||||
for (const [key, { message, code }] of Object.entries(fields)) {
|
||||
errorObj[key] = {
|
||||
_errors: [
|
||||
{
|
||||
message,
|
||||
@@ -40,9 +39,9 @@ export function FieldErrors(fields: Record<string, { code?: string; message: str
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return new FieldError(50035, "Invalid Form Body", errorsObject, errors);
|
||||
return new FieldError(50035, "Invalid Form Body", errorObj, errors);
|
||||
}
|
||||
|
||||
// TODO: implement Image data type: Data URI scheme that supports JPG, GIF, and PNG formats. An example Data URI format is: data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA
|
||||
@@ -52,7 +51,7 @@ export class FieldError extends Error {
|
||||
constructor(
|
||||
public code: string | number,
|
||||
public message: string,
|
||||
public errors?: object, // TODO: I don't like this typing.
|
||||
public errors?: ErrorList,
|
||||
public _ajvErrors?: ErrorObject[],
|
||||
) {
|
||||
super(message);
|
||||
|
||||
Reference in New Issue
Block a user