mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
minor bugfixes
This commit is contained in:
parent
8236d151ed
commit
be25b9e068
@ -66,14 +66,11 @@ export class RenderingMWs {
|
||||
if (err.details) {
|
||||
Logger.warn('Handled error:');
|
||||
console.log(err);
|
||||
delete (err.details); // do not send back error object to the client side
|
||||
|
||||
// hide error details for non developers
|
||||
if (!(req.session.user && req.session.user.role >= UserRoles.Developer)) {
|
||||
delete (err.details);
|
||||
} else {
|
||||
try {
|
||||
err.details = err.details.toString() || err.details;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
delete (err.detailsStr);
|
||||
}
|
||||
}
|
||||
const message = new Message<any>(err, null);
|
||||
|
@ -9,7 +9,7 @@ import {MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {ThumbnailGeneratorMWs} from '../../../middlewares/thumbnail/ThumbnailGeneratorMWs';
|
||||
import {Task} from './Task';
|
||||
import {ConfigTemplateEntry, DefaultsTasks, TaskDTO} from '../../../../common/entities/task/TaskDTO';
|
||||
import {ConfigTemplateEntry, DefaultsTasks} from '../../../../common/entities/task/TaskDTO';
|
||||
import {ServerConfig} from '../../../../common/config/private/IPrivateConfig';
|
||||
|
||||
declare const global: any;
|
||||
|
@ -23,10 +23,13 @@ export enum ErrorCodes {
|
||||
}
|
||||
|
||||
export class ErrorDTO {
|
||||
public detailsStr: string;
|
||||
|
||||
constructor(public code: ErrorCodes, public message?: string, public details?: any) {
|
||||
this.detailsStr = (this.details ? this.details.toString() : '');
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return '[' + ErrorCodes[this.code] + '] ' + this.message + (this.details ? this.details.toString() : '');
|
||||
return '[' + ErrorCodes[this.code] + '] ' + this.message + this.detailsStr;
|
||||
}
|
||||
}
|
||||
|
@ -32,25 +32,33 @@ export class NotificationService {
|
||||
});
|
||||
}
|
||||
|
||||
get Toastr(): ToastrService {
|
||||
return this._toastr;
|
||||
}
|
||||
|
||||
async getServerNotifications() {
|
||||
this.notifications = await this._networkService.getJson<NotificationDTO[]>('/notifications');
|
||||
this.notifications.forEach((noti) => {
|
||||
let msg = noti.message;
|
||||
if (noti.details) {
|
||||
msg += ' Details: ' + JSON.stringify(noti.details);
|
||||
}
|
||||
switch (noti.type) {
|
||||
case NotificationType.error:
|
||||
this.error(msg, this.i18n('Server error'));
|
||||
break;
|
||||
case NotificationType.warning:
|
||||
this.warning(msg, this.i18n('Server error'));
|
||||
break;
|
||||
case NotificationType.info:
|
||||
this.info(msg, this.i18n('Server info'));
|
||||
break;
|
||||
}
|
||||
});
|
||||
try {
|
||||
this.notifications = (await this._networkService.getJson<NotificationDTO[]>('/notifications')) || [];
|
||||
this.notifications.forEach((noti) => {
|
||||
let msg = noti.message;
|
||||
if (noti.details) {
|
||||
msg += ' Details: ' + JSON.stringify(noti.details);
|
||||
}
|
||||
switch (noti.type) {
|
||||
case NotificationType.error:
|
||||
this.error(msg, this.i18n('Server error'));
|
||||
break;
|
||||
case NotificationType.warning:
|
||||
this.warning(msg, this.i18n('Server error'));
|
||||
break;
|
||||
case NotificationType.info:
|
||||
this.info(msg, this.i18n('Server info'));
|
||||
break;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
success(text: string, title: string = null): void {
|
||||
@ -68,9 +76,4 @@ export class NotificationService {
|
||||
info(text: string, title: string = null): void {
|
||||
this._toastr.info(text, title, this.options);
|
||||
}
|
||||
|
||||
|
||||
get Toastr(): ToastrService {
|
||||
return this._toastr;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user