throw error if failed

This commit is contained in:
Namekuji 2023-07-02 22:21:19 -04:00
parent 284c0db1fd
commit b36cc31e9b
2 changed files with 4 additions and 14 deletions

View file

@ -6,7 +6,7 @@ import { ApiError } from "../../../error.js";
import rndstr from "rndstr";
import { publishBroadcastStream } from "@/services/stream.js";
import { db } from "@/db/postgre.js";
import { type Size, getEmojiSize } from "@/misc/emoji-meta.js";
import { getEmojiSize } from "@/misc/emoji-meta.js";
export const meta = {
tags: ["admin"],
@ -40,12 +40,7 @@ export default define(meta, paramDef, async (ps, me) => {
? file.name.split(".")[0]
: `_${rndstr("a-z0-9", 8)}_`;
let size: Size = { width: 0, height: 0 };
try {
size = await getEmojiSize(file.url);
} catch {
/* skip if any error happens */
}
const size = await getEmojiSize(file.url);
const emoji = await Emojis.insert({
id: genId(),

View file

@ -6,7 +6,7 @@ import type { DriveFile } from "@/models/entities/drive-file.js";
import { uploadFromUrl } from "@/services/drive/upload-from-url.js";
import { publishBroadcastStream } from "@/services/stream.js";
import { db } from "@/db/postgre.js";
import { type Size, getEmojiSize } from "@/misc/emoji-meta.js";
import { getEmojiSize } from "@/misc/emoji-meta.js";
export const meta = {
tags: ["admin"],
@ -65,12 +65,7 @@ export default define(meta, paramDef, async (ps, me) => {
throw new ApiError();
}
let size: Size = { width: 0, height: 0 };
try {
size = await getEmojiSize(driveFile.url);
} catch {
/* skip if any error happens */
}
const size = await getEmojiSize(driveFile.url);
const copied = await Emojis.insert({
id: genId(),