Skip to content

Commit

Permalink
errors not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasvo committed Sep 20, 2024
1 parent 3442d88 commit c457931
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions example/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs';
import path from 'path';
import { inspect } from 'util';
const md5File = require('md5-file');
import formidable from 'formidable';
import { formidable } from 'formidable';
import { PassThrough } from 'stream';

const router = express.Router();
Expand Down Expand Up @@ -45,7 +45,11 @@ router.post('/multipart-upload', async (req, res) => {
} catch (err) {
console.error(err);
let httpCode =
err instanceof formidable.errors.FormidableError && err.httpCode;
!!err &&
typeof err === 'object' &&
'httpCode' in err &&
Number(err.httpCode);

httpCode ||= 500;
res.writeHead(httpCode, { 'Content-Type': 'text/plain' });
res.end(String(err));
Expand Down

0 comments on commit c457931

Please sign in to comment.