Skip to content

Commit

Permalink
Merge branch 'staging' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Sep 22, 2024
2 parents 6daa315 + a3b5b4b commit 6f7c80e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
9 changes: 2 additions & 7 deletions app/api/csv/arrangeThesauri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ import { LabelInfoBase } from './typeParsers/select';
import { headerWithLanguage } from './csvDefinitions';

class ArrangeThesauriError extends Error {
source: Error;

row: CSVRow;

index: number;

constructor(source: Error, row: CSVRow, index: number) {
super(source.message);
this.source = source;
super(source.message, { cause: source });
this.row = row;
this.index = index;
}
Expand Down Expand Up @@ -163,9 +160,7 @@ const tryAddingLabel = (
const map = thesauriValueData[id];
if (isStandaloneGroup(map, labelInfo)) {
throw new Error(
`The label "${
labelInfo.label
}" at property "${name}" is a group label in line:\n${JSON.stringify(row)}`
`The label "${labelInfo.label}" at property "${name}" is a group label in line:\n${JSON.stringify(row)}`
);
}
const { childInfo, parentInfo } = pickParentChild(labelInfo);
Expand Down
7 changes: 2 additions & 5 deletions app/api/files/S3Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import {
import { config } from 'api/config';

class S3TimeoutError extends Error {
readonly s3TimeoutError: Error;

constructor(s3TimeoutError: Error) {
super(s3TimeoutError.message);
this.s3TimeoutError = s3TimeoutError;
constructor(cause: Error) {
super(cause.message, { cause });
}
}

Expand Down
11 changes: 6 additions & 5 deletions app/api/utils/handleError.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { legacyLogger } from 'api/log';
import Ajv from 'ajv';
import { createError } from 'api/utils/index';
import { appContext } from 'api/utils/AppContext';
import { UnauthorizedError } from 'api/authorization.v2/errors/UnauthorizedError';
import { ValidationError } from 'api/common.v2/validation/ValidationError';
import { FileNotFound } from 'api/files/FileNotFound';
import { S3TimeoutError } from 'api/files/S3Storage';
import { legacyLogger } from 'api/log';
import { appContext } from 'api/utils/AppContext';
import { createError } from 'api/utils/index';
import util from 'node:util';

const ajvPrettifier = error => {
const errorMessage = [error.message];
Expand Down Expand Up @@ -60,11 +61,11 @@ const prettifyError = (error, { req = {}, uncaught = false } = {}) => {
let result = error;

if (error instanceof Error) {
result = { code: 500, message: error.stack, logLevel: 'error' };
result = { code: 500, message: util.inspect(error), logLevel: 'error' };
}

if (error instanceof S3TimeoutError) {
result = { code: 408, message: `${error.message}\n${error.stack}`, logLevel: 'debug' };
result = { code: 408, message: util.inspect(error), logLevel: 'debug' };
}

if (error instanceof Ajv.ValidationError) {
Expand Down
7 changes: 4 additions & 3 deletions app/api/utils/specs/handleError.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { createError } from 'api/utils';
import { legacyLogger } from 'api/log';
import { createError } from 'api/utils';

import { errors as elasticErrors } from '@elastic/elasticsearch';
import { S3TimeoutError } from 'api/files/S3Storage';
import { appContext } from 'api/utils/AppContext';
import util from 'node:util';
import { handleError, prettifyError } from '../handleError';
import { S3TimeoutError } from 'api/files/S3Storage';

const contextRequestId = '1234';

Expand Down Expand Up @@ -48,7 +49,7 @@ describe('handleError', () => {
handleError(error);

expect(legacyLogger.error).toHaveBeenCalledWith(
`requestId: ${contextRequestId} \n${error.stack}
`requestId: ${contextRequestId} \n${util.inspect(error)}
original error: {
"name": "ConnectionError",
"meta": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.185.0-rc6",
"version": "1.185.0-rc7",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down

0 comments on commit 6f7c80e

Please sign in to comment.