reduce, clarify, and normalize more error messages
This commit is contained in:
parent
b2c5029c3e
commit
ce08bd1b42
34 changed files with 114 additions and 97 deletions
|
|
@ -46,6 +46,7 @@ import { ModerationLogService } from '@/core/ModerationLogService.js';
|
|||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { BunnyService } from '@/core/BunnyService.js';
|
||||
import { LoggerService } from './LoggerService.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
|
||||
type AddFileArgs = {
|
||||
/** User who wish to add file */
|
||||
|
|
@ -311,7 +312,7 @@ export class DriveService {
|
|||
thumbnail,
|
||||
};
|
||||
} catch (err) {
|
||||
this.registerLogger.warn(`GenerateVideoThumbnail failed: ${err}`);
|
||||
this.registerLogger.warn(`GenerateVideoThumbnail failed: ${renderInlineError(err)}`);
|
||||
return {
|
||||
webpublic: null,
|
||||
thumbnail: null,
|
||||
|
|
@ -344,7 +345,7 @@ export class DriveService {
|
|||
metadata.height && metadata.height <= 2048
|
||||
);
|
||||
} catch (err) {
|
||||
this.registerLogger.warn(`sharp failed: ${err}`);
|
||||
this.registerLogger.warn(`sharp failed: ${renderInlineError(err)}`);
|
||||
return {
|
||||
webpublic: null,
|
||||
thumbnail: null,
|
||||
|
|
@ -651,7 +652,7 @@ export class DriveService {
|
|||
userId: user ? user.id : IsNull(),
|
||||
}) as MiDriveFile;
|
||||
} else {
|
||||
this.registerLogger.error(err as Error);
|
||||
this.registerLogger.error('Error in drive register', err as Error);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
@ -895,7 +896,7 @@ export class DriveService {
|
|||
this.downloaderLogger.succ(`Got: ${driveFile.id}`);
|
||||
return driveFile!;
|
||||
} catch (err) {
|
||||
this.downloaderLogger.error(`Failed to create drive file: ${err}`, {
|
||||
this.downloaderLogger.error(`Failed to create drive file: ${renderInlineError(err)}`, {
|
||||
url: url,
|
||||
e: err,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { LoggerService } from '@/core/LoggerService.js';
|
|||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import type { CheerioAPI } from 'cheerio';
|
||||
|
||||
type NodeInfo = {
|
||||
|
|
@ -130,7 +131,7 @@ export class FetchInstanceMetadataService {
|
|||
|
||||
this.logger.succ(`Successfuly updated metadata of ${instance.host}`);
|
||||
} catch (e) {
|
||||
this.logger.error(`Failed to update metadata of ${instance.host}: ${e}`);
|
||||
this.logger.error(`Failed to update metadata of ${instance.host}: ${renderInlineError(e)}`);
|
||||
} finally {
|
||||
await this.unlock(host);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -549,8 +549,6 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
throw err;
|
||||
}
|
||||
|
||||
console.error(e);
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import type { Config } from '@/config.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { MiUser } from '@/models/_.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import Logger from '@/logger.js';
|
||||
import type {
|
||||
AuthenticationResponseJSON,
|
||||
AuthenticatorTransportFuture,
|
||||
|
|
@ -28,6 +30,8 @@ import type {
|
|||
|
||||
@Injectable()
|
||||
export class WebAuthnService {
|
||||
private readonly logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
|
@ -40,7 +44,9 @@ export class WebAuthnService {
|
|||
|
||||
@Inject(DI.userSecurityKeysRepository)
|
||||
private userSecurityKeysRepository: UserSecurityKeysRepository,
|
||||
loggerService: LoggerService,
|
||||
) {
|
||||
this.logger = loggerService.getLogger('web-authn');
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
|
@ -114,7 +120,7 @@ export class WebAuthnService {
|
|||
requireUserVerification: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.logger.error(error as Error, 'Error authenticating webauthn');
|
||||
throw new IdentifiableError('5c1446f8-8ca7-4d31-9f39-656afe9c5d87', 'verification failed');
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +307,7 @@ export class WebAuthnService {
|
|||
requireUserVerification: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.logger.error(error as Error, 'Error authenticating webauthn');
|
||||
throw new IdentifiableError('b18c89a7-5b5e-4cec-bb5b-0419f332d430', 'verification failed');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { XMLParser } from 'fast-xml-parser';
|
|||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { RemoteLoggerService } from './RemoteLoggerService.js';
|
||||
|
||||
export type ILink = {
|
||||
|
|
@ -109,7 +110,7 @@ export class WebfingerService {
|
|||
const template = (hostMeta['XRD']['Link'] as Array<any>).filter(p => p['@_rel'] === 'lrdd')[0]['@_template'];
|
||||
return template.indexOf('{uri}') < 0 ? null : template;
|
||||
} catch (err) {
|
||||
this.logger.error(`error while request host-meta for ${url}: ${err}`);
|
||||
this.logger.error(`error while request host-meta for ${url}: ${renderInlineError(err)}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import { AbuseReportService } from '@/core/AbuseReportService.js';
|
|||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||
import { fromTuple } from '@/misc/from-tuple.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import InstanceChart from '@/core/chart/charts/instance.js';
|
||||
import FederationChart from '@/core/chart/charts/federation.js';
|
||||
import { FetchInstanceMetadataService } from '@/core/FetchInstanceMetadataService.js';
|
||||
|
|
@ -127,7 +128,7 @@ export class ApInboxService {
|
|||
results.push([id, result]);
|
||||
} catch (err) {
|
||||
if (err instanceof Error || typeof err === 'string') {
|
||||
this.logger.error(err);
|
||||
this.logger.error(`Unhandled error in activity ${getNullableApId(item || 'undefined')}:`, err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
|
|
@ -253,7 +254,7 @@ export class ApInboxService {
|
|||
resolver ??= this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(err => {
|
||||
this.logger.error(`Resolution failed: ${err}`);
|
||||
this.logger.error(`Resolution failed: ${renderInlineError(err)}`);
|
||||
throw err;
|
||||
});
|
||||
|
||||
|
|
@ -326,7 +327,7 @@ export class ApInboxService {
|
|||
if (targetUri.startsWith('bear:')) return 'skip: bearcaps url not supported.';
|
||||
|
||||
const target = await resolver.secureResolve(activityObject, uri).catch(e => {
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${renderInlineError(e)}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
|
|
@ -499,7 +500,7 @@ export class ApInboxService {
|
|||
resolver ??= this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activityObject).catch(e => {
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${renderInlineError(e)}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
|
|
@ -668,7 +669,7 @@ export class ApInboxService {
|
|||
resolver ??= this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${renderInlineError(e)}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
|
|
@ -740,7 +741,7 @@ export class ApInboxService {
|
|||
resolver ??= this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${renderInlineError(e)}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
|
|
@ -872,7 +873,7 @@ export class ApInboxService {
|
|||
resolver ??= this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${renderInlineError(e)}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import { bindThis } from '@/decorators.js';
|
|||
import { checkHttps } from '@/misc/check-https.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { isRetryableError } from '@/misc/is-retryable-error.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { getOneApId, getApId, validPost, isEmoji, getApType, isApObject, isDocument, IApDocument } from '../type.js';
|
||||
import { ApLoggerService } from '../ApLoggerService.js';
|
||||
import { ApMfmService } from '../ApMfmService.js';
|
||||
|
|
@ -161,7 +162,7 @@ export class ApNoteService {
|
|||
const entryUri = getApId(value);
|
||||
const err = this.validateNote(object, entryUri, actor);
|
||||
if (err) {
|
||||
this.logger.error(err.message, {
|
||||
this.logger.error(`Error creating note: ${renderInlineError(err)}`, {
|
||||
resolver: { history: resolver.getHistory() },
|
||||
value,
|
||||
object,
|
||||
|
|
@ -269,14 +270,14 @@ export class ApNoteService {
|
|||
? await this.resolveNote(note.inReplyTo, { resolver })
|
||||
.then(x => {
|
||||
if (x == null) {
|
||||
this.logger.warn('Specified inReplyTo, but not found');
|
||||
this.logger.warn(`Specified inReplyTo "${note.inReplyTo}", but not found`);
|
||||
throw new Error(`could not fetch inReplyTo ${note.inReplyTo} for note ${entryUri}`);
|
||||
}
|
||||
|
||||
return x;
|
||||
})
|
||||
.catch(async err => {
|
||||
this.logger.warn(`error ${err.statusCode ?? err} fetching inReplyTo ${note.inReplyTo} for note ${entryUri}`);
|
||||
this.logger.warn(`error ${renderInlineError(err)} fetching inReplyTo ${note.inReplyTo} for note ${entryUri}`);
|
||||
throw err;
|
||||
})
|
||||
: null;
|
||||
|
|
@ -379,7 +380,7 @@ export class ApNoteService {
|
|||
const entryUri = getApId(value);
|
||||
const err = this.validateNote(object, entryUri, actor, user);
|
||||
if (err) {
|
||||
this.logger.error(err.message, {
|
||||
this.logger.error(`Error updating note: ${renderInlineError(err)}`, {
|
||||
resolver: { history: resolver.getHistory() },
|
||||
value,
|
||||
object,
|
||||
|
|
@ -473,14 +474,14 @@ export class ApNoteService {
|
|||
? await this.resolveNote(note.inReplyTo, { resolver })
|
||||
.then(x => {
|
||||
if (x == null) {
|
||||
this.logger.warn('Specified inReplyTo, but not found');
|
||||
this.logger.warn(`Specified inReplyTo "${note.inReplyTo}", but not found`);
|
||||
throw new Error(`could not fetch inReplyTo ${note.inReplyTo} for note ${entryUri}`);
|
||||
}
|
||||
|
||||
return x;
|
||||
})
|
||||
.catch(async err => {
|
||||
this.logger.warn(`error ${err.statusCode ?? err} fetching inReplyTo ${note.inReplyTo} for note ${entryUri}`);
|
||||
this.logger.warn(`error ${renderInlineError(err)} fetching inReplyTo ${note.inReplyTo} for note ${entryUri}`);
|
||||
throw err;
|
||||
})
|
||||
: null;
|
||||
|
|
@ -685,18 +686,13 @@ export class ApNoteService {
|
|||
const quote = await this.resolveNote(uri, { resolver });
|
||||
|
||||
if (quote == null) {
|
||||
this.logger.warn(`Failed to resolve quote "${uri}" for note "${entryUri}": request error`);
|
||||
this.logger.warn(`Failed to resolve quote "${uri}" for note "${entryUri}": fetch failed`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return quote;
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
this.logger.warn(`Failed to resolve quote "${uri}" for note "${entryUri}":`, e);
|
||||
} else {
|
||||
this.logger.warn(`Failed to resolve quote "${uri}" for note "${entryUri}": ${e}`);
|
||||
}
|
||||
|
||||
this.logger.warn(`Failed to resolve quote "${uri}" for note "${entryUri}": ${renderInlineError(e)}`);
|
||||
return isRetryableError(e);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue