Skip to content

Commit aa7354e

Browse files
committed
chore: show error logs properly
1 parent 61839db commit aa7354e

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

ee/packages/federation-matrix/src/FederationMatrix.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
228228

229229
return matrixRoomResult;
230230
} catch (error) {
231-
this.logger.error('Failed to create room:', error);
231+
this.logger.error(error, 'Failed to create room');
232232
throw error;
233233
}
234234
}
@@ -302,7 +302,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
302302
userIdSchema.parse(actualMatrixUserId),
303303
);
304304
} catch (error) {
305-
this.logger.error('Error creating or updating bridged user for DM:', error);
305+
this.logger.error(error, 'Error creating or updating bridged user for DM');
306306
}
307307
}
308308
}
@@ -311,9 +311,9 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
311311
mrid: matrixRoomResult.room_id,
312312
origin: this.serverName,
313313
});
314-
this.logger.debug('Direct message room creation completed successfully', room._id);
314+
this.logger.debug(room._id, 'Direct message room creation completed successfully');
315315
} catch (error) {
316-
this.logger.error('Failed to create direct message room:', error);
316+
this.logger.error(error, 'Failed to create direct message room');
317317
throw error;
318318
}
319319
}
@@ -367,9 +367,10 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
367367

368368
return lastEventId;
369369
} catch (error) {
370-
this.logger.error('Failed to handle file message', {
370+
this.logger.error({
371+
msg: 'Failed to handle file message',
371372
messageId: message._id,
372-
error,
373+
err: error,
373374
});
374375
throw error;
375376
}
@@ -464,7 +465,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
464465

465466
this.logger.debug('Message sent to Matrix successfully:', result.eventId);
466467
} catch (error) {
467-
this.logger.error('Failed to send message to Matrix:', error);
468+
this.logger.error(error, 'Failed to send message to Matrix');
468469
throw error;
469470
}
470471
}
@@ -526,7 +527,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
526527

527528
this.logger.debug('Message Redaction sent to Matrix successfully:', eventId);
528529
} catch (error) {
529-
this.logger.error('Failed to send redaction to Matrix:', error);
530+
this.logger.error(error, 'Failed to send redaction to Matrix');
530531
throw error;
531532
}
532533
}
@@ -560,7 +561,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
560561
}),
561562
);
562563
} catch (error) {
563-
this.logger.error('Failed to invite a user to Matrix:', error);
564+
this.logger.error(error, 'Failed to invite a user to Matrix');
564565
throw error;
565566
}
566567
}
@@ -597,7 +598,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
597598

598599
this.logger.debug('Reaction sent to Matrix successfully:', eventId);
599600
} catch (error) {
600-
this.logger.error('Failed to send reaction to Matrix:', error);
601+
this.logger.error(error, 'Failed to send reaction to Matrix');
601602
throw error;
602603
}
603604
}
@@ -651,7 +652,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
651652
break;
652653
}
653654
} catch (error) {
654-
this.logger.error('Failed to remove reaction from Matrix:', error);
655+
this.logger.error(error, 'Failed to remove reaction from Matrix');
655656
throw error;
656657
}
657658
}
@@ -679,7 +680,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
679680

680681
this.logger.info(`User ${user.username} left Matrix room ${room.federation.mrid} successfully`);
681682
} catch (error) {
682-
this.logger.error('Failed to leave room in Matrix:', error);
683+
this.logger.error(error, 'Failed to leave room in Matrix');
683684
throw error;
684685
}
685686
}
@@ -703,7 +704,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
703704

704705
this.logger.info(`User ${removedUser.username} was kicked from Matrix room ${room.federation.mrid} by ${userWhoRemoved.username}`);
705706
} catch (error) {
706-
this.logger.error('Failed to kick user from Matrix room:', error);
707+
this.logger.error(error, 'Failed to kick user from Matrix room');
707708
throw error;
708709
}
709710
}
@@ -738,7 +739,7 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
738739

739740
this.logger.debug('Message updated in Matrix successfully:', eventId);
740741
} catch (error) {
741-
this.logger.error('Failed to update message in Matrix:', error);
742+
this.logger.error(error, 'Failed to update message in Matrix');
742743
throw error;
743744
}
744745
}

ee/packages/federation-matrix/src/events/edu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const edus = async (emitter: Emitter<HomeserverEventSignatures>) => {
2727
roomId: matrixRoom._id,
2828
});
2929
} catch (error) {
30-
logger.error('Error handling Matrix typing event:', error);
30+
logger.error(error, 'Error handling Matrix typing event');
3131
}
3232
});
3333

@@ -79,7 +79,7 @@ export const edus = async (emitter: Emitter<HomeserverEventSignatures>) => {
7979
});
8080
logger.debug(`Updated presence for user ${matrixUser._id} to ${status} from Matrix federation`);
8181
} catch (error) {
82-
logger.error('Error handling Matrix presence event:', error);
82+
logger.error(error, 'Error handling Matrix presence event');
8383
}
8484
});
8585
};

ee/packages/federation-matrix/src/events/member.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export function member(emitter: Emitter<HomeserverEventSignatures>) {
231231
logger.warn(`Unknown membership type: ${event.content.membership}`);
232232
}
233233
} catch (error) {
234-
logger.error('Failed to process Matrix membership event:', error);
234+
logger.error(error, 'Failed to process Matrix membership event');
235235
}
236236
});
237237
}

ee/packages/federation-matrix/src/events/message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export function message(emitter: Emitter<HomeserverEventSignatures>) {
413413

414414
await Message.deleteMessage(user, rcMessage);
415415
} catch (error) {
416-
logger.error('Failed to process Matrix removal redaction:', error);
416+
logger.error(error, 'Failed to process Matrix removal redaction');
417417
}
418418
});
419419
}

ee/packages/federation-matrix/src/events/reaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function reaction(emitter: Emitter<HomeserverEventSignatures>) {
4343
await Message.reactToMessage(user._id, reactionEmoji, rcMessage._id, true);
4444
await Messages.setFederationReactionEventId(internalUsername, rcMessage._id, reactionEmoji, eventId);
4545
} catch (error) {
46-
logger.error('Failed to process Matrix reaction:', error);
46+
logger.error(error, 'Failed to process Matrix reaction');
4747
}
4848
});
4949

@@ -87,7 +87,7 @@ export function reaction(emitter: Emitter<HomeserverEventSignatures>) {
8787
await Message.reactToMessage(user._id, reactionEmoji, rcMessage._id, false);
8888
await Messages.unsetFederationReactionEventId(redactedEventId, rcMessage._id, reactionEmoji);
8989
} catch (error) {
90-
logger.error('Failed to process Matrix reaction redaction:', error);
90+
logger.error(error, 'Failed to process Matrix reaction redaction');
9191
}
9292
});
9393
}

ee/packages/federation-matrix/src/services/MatrixMediaService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class MatrixMediaService {
5555

5656
return mxcUri;
5757
} catch (error) {
58-
logger.error('Error preparing file for Matrix:', error);
58+
logger.error(error, 'Error preparing file for Matrix');
5959
throw error;
6060
}
6161
}
@@ -74,7 +74,7 @@ export class MatrixMediaService {
7474

7575
return file;
7676
} catch (error) {
77-
logger.error('Error retrieving local file:', error);
77+
logger.error(error, 'Error retrieving local file');
7878
return null;
7979
}
8080
}
@@ -130,7 +130,7 @@ export class MatrixMediaService {
130130

131131
return uploadedFile._id;
132132
} catch (error) {
133-
logger.error('Error downloading and storing remote file:', error);
133+
logger.error(error, 'Error downloading and storing remote file');
134134
throw error;
135135
}
136136
}

0 commit comments

Comments
 (0)