1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Improving debugging and error handling.

This commit is contained in:
Patrik J. Braun 2023-01-08 11:09:16 +01:00
parent 353e40c6e9
commit 3df1f43031
4 changed files with 27 additions and 13 deletions

View File

@ -10,6 +10,8 @@ import {Utils} from '../../common/Utils';
import {LoggerRouter} from '../routes/LoggerRouter';
import {TAGS} from '../../common/config/public/ClientConfig';
const forcedDebug = process.env['NODE_ENV'] === 'debug';
export class RenderingMWs {
public static renderResult(
req: Request,
@ -135,9 +137,10 @@ export class RenderingMWs {
// hide error details for non developers
if (
!(
req.session &&
req.session['user'] &&
req.session['user'].role >= UserRoles.Developer
forcedDebug ||
(req.session &&
req.session['user'] &&
req.session['user'].role >= UserRoles.Developer)
)
) {
delete err.detailsStr;

View File

@ -2,6 +2,7 @@ import { NextFunction, Request, Response } from 'express';
import * as fs from 'fs';
import { PhotoProcessing } from '../../model/fileprocessing/PhotoProcessing';
import { Config } from '../../../common/config/private/Config';
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
export class PhotoConverterMWs {
public static async convertPhoto(
@ -30,7 +31,11 @@ export class PhotoConverterMWs {
}
if (Config.Media.Photo.Converting.onTheFly === true) {
req.resultPipe = await PhotoProcessing.convertPhoto(fullMediaPath);
try {
req.resultPipe = await PhotoProcessing.convertPhoto(fullMediaPath);
}catch (err){
return next(new ErrorDTO(ErrorCodes.PHOTO_GENERATION_ERROR, err.message));
}
return next();
}

View File

@ -274,6 +274,11 @@ export class ConfigDiagnostics {
}
static async runDiagnostics(): Promise<void> {
if (process.env['NODE_ENV'] === 'debug') {
NotificationManager.warning('You are running the application with NODE_ENV=debug. This exposes a lot of debug information that can be a security vulnerability. Set NODE_ENV=production, when you finished debugging.');
}
try {
await ConfigDiagnostics.testDatabase(Config.Database);
} catch (ex) {

View File

@ -11,19 +11,20 @@ export enum ErrorCodes {
GENERAL_ERROR = 7,
THUMBNAIL_GENERATION_ERROR = 8,
PERSON_ERROR = 9,
SERVER_ERROR = 10,
PHOTO_GENERATION_ERROR = 9,
PERSON_ERROR = 10,
SERVER_ERROR = 11,
USER_MANAGEMENT_DISABLED = 11,
USER_MANAGEMENT_DISABLED = 12,
INPUT_ERROR = 12,
INPUT_ERROR = 13,
SETTINGS_ERROR = 13,
TASK_ERROR = 14,
JOB_ERROR = 15,
LocationLookUp_ERROR = 16,
SETTINGS_ERROR = 14,
TASK_ERROR = 15,
JOB_ERROR = 16,
LocationLookUp_ERROR = 17,
ALBUM_ERROR = 17,
ALBUM_ERROR = 18,
}
export class ErrorDTO {