Improving error throwing and handling in pusher/admin/front
This commit is contained in:
parent
9bfd07f00c
commit
cd7a332b4c
4 changed files with 21 additions and 9 deletions
|
@ -13,8 +13,20 @@ export class BaseController {
|
|||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
protected errorToResponse(e: any, res: HttpResponse): void {
|
||||
console.error(e.message || "An error happened.", e?.config.url);
|
||||
console.error(e.stack || 'no stack defined.');
|
||||
if (e && e.message) {
|
||||
let url = e?.config?.url;
|
||||
if (url !== undefined) {
|
||||
url = ' for URL: '+url;
|
||||
} else {
|
||||
url = '';
|
||||
}
|
||||
console.error('ERROR: '+e.message+url);
|
||||
} else if (typeof(e) === 'string') {
|
||||
console.error(e);
|
||||
}
|
||||
if (e.stack) {
|
||||
console.error(e.stack);
|
||||
}
|
||||
if (e.response) {
|
||||
res.writeStatus(e.response.status+" "+e.response.statusText);
|
||||
this.addCorsHeaders(res);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue