forked from FoundKeyGang/FoundKey
Better error handling
This commit is contained in:
parent
bd207b5012
commit
5d0ded2a69
1 changed files with 32 additions and 21 deletions
|
@ -80,27 +80,38 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
|
||||||
const summaryDOM = JSDOM.fragment(person.summary);
|
const summaryDOM = JSDOM.fragment(person.summary);
|
||||||
|
|
||||||
// Create user
|
// Create user
|
||||||
const user = await User.insert({
|
let user: IRemoteUser;
|
||||||
avatarId: null,
|
try {
|
||||||
bannerId: null,
|
user = await User.insert({
|
||||||
createdAt: Date.parse(person.published) || null,
|
avatarId: null,
|
||||||
description: summaryDOM.textContent,
|
bannerId: null,
|
||||||
followersCount,
|
createdAt: Date.parse(person.published) || null,
|
||||||
followingCount,
|
description: summaryDOM.textContent,
|
||||||
notesCount,
|
followersCount,
|
||||||
name: person.name,
|
followingCount,
|
||||||
driveCapacity: 1024 * 1024 * 8, // 8MiB
|
notesCount,
|
||||||
username: person.preferredUsername,
|
name: person.name,
|
||||||
usernameLower: person.preferredUsername.toLowerCase(),
|
driveCapacity: 1024 * 1024 * 8, // 8MiB
|
||||||
host,
|
username: person.preferredUsername,
|
||||||
publicKey: {
|
usernameLower: person.preferredUsername.toLowerCase(),
|
||||||
id: person.publicKey.id,
|
host,
|
||||||
publicKeyPem: person.publicKey.publicKeyPem
|
publicKey: {
|
||||||
},
|
id: person.publicKey.id,
|
||||||
inbox: person.inbox,
|
publicKeyPem: person.publicKey.publicKeyPem
|
||||||
uri: person.id,
|
},
|
||||||
url: person.url
|
inbox: person.inbox,
|
||||||
}) as IRemoteUser;
|
uri: person.id,
|
||||||
|
url: person.url
|
||||||
|
}) as IRemoteUser;
|
||||||
|
} catch (e) {
|
||||||
|
// duplicate key error
|
||||||
|
if (e.code === 11000) {
|
||||||
|
throw new Error('already registered');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
//#region アイコンとヘッダー画像をフェッチ
|
//#region アイコンとヘッダー画像をフェッチ
|
||||||
const [avatarId, bannerId] = (await Promise.all([
|
const [avatarId, bannerId] = (await Promise.all([
|
||||||
|
|
Loading…
Reference in a new issue