mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 13:13:09 +02:00
Better error handling
This commit is contained in:
parent
bd207b5012
commit
5d0ded2a69
1 changed files with 32 additions and 21 deletions
|
@ -80,7 +80,9 @@ 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;
|
||||||
|
try {
|
||||||
|
user = await User.insert({
|
||||||
avatarId: null,
|
avatarId: null,
|
||||||
bannerId: null,
|
bannerId: null,
|
||||||
createdAt: Date.parse(person.published) || null,
|
createdAt: Date.parse(person.published) || null,
|
||||||
|
@ -101,6 +103,15 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
|
||||||
uri: person.id,
|
uri: person.id,
|
||||||
url: person.url
|
url: person.url
|
||||||
}) as IRemoteUser;
|
}) 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