Skip to content

Commit 15ff40b

Browse files
committed
Properly export all error classes from form-data-parser
1 parent 496dcb0 commit 15ff40b

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

packages/form-data-parser/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This is the changelog for [`form-data-parser`](https://github.com/mjackson/remix-the-web/tree/main/packages/form-data-parser). It follows [semantic versioning](https://semver.org/).
44

5+
## HEAD
6+
7+
- Export `FormDataParserError` and `MaxFilesExceededError`
8+
- Re-export `MultipartParseError`, `MaxHeaderSizeExceededError`, and `MaxFileSizeExceededError` from multipart parser
9+
510
## v0.9.0 (2025-06-13)
611

712
This release updates to `multipart-parser` 0.10.0 and removes the restrictions on checking the `size` and/or `slice`ing `FileUpload` objects.

packages/form-data-parser/examples/node/server.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import * as fsp from 'node:fs/promises';
22
import * as http from 'node:http';
33
import * as os from 'node:os';
44
import * as path from 'node:path';
5+
56
import { LocalFileStorage } from '@mjackson/file-storage/local';
6-
import { parseFormData } from '@mjackson/form-data-parser';
7-
import { MultipartParseError, MaxFileSizeExceededError } from '@mjackson/multipart-parser';
7+
import {
8+
MultipartParseError,
9+
MaxFileSizeExceededError,
10+
parseFormData,
11+
} from '@mjackson/form-data-parser';
812
import { createRequestListener } from '@mjackson/node-fetch-server';
913

1014
const PORT = 3000;
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
export { FileUpload, type FileUploadHandler, parseFormData } from './lib/form-data.ts';
1+
export type { FileUploadHandler } from './lib/form-data.ts';
2+
export {
3+
FormDataParseError,
4+
MaxFilesExceededError,
5+
FileUpload,
6+
parseFormData,
7+
} from './lib/form-data.ts';
8+
9+
// Re-export errors that may be thrown by the parser.
10+
export {
11+
MultipartParseError,
12+
MaxHeaderSizeExceededError,
13+
MaxFileSizeExceededError,
14+
} from '@mjackson/multipart-parser';

packages/form-data-parser/src/lib/form-data.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import {
55
MultipartPart,
66
} from '@mjackson/multipart-parser';
77

8+
/**
9+
* The base class for errors thrown by the form data parser.
10+
*/
811
export class FormDataParseError extends Error {
912
constructor(message: string) {
1013
super(message);
1114
this.name = 'FormDataParseError';
1215
}
1316
}
1417

18+
/**
19+
* An error thrown when the maximum number of files allowed in a request is exceeded.
20+
*/
1521
export class MaxFilesExceededError extends FormDataParseError {
1622
constructor(maxFiles: number) {
1723
super(`Maximum number of files exceeded: ${maxFiles}`);

0 commit comments

Comments
 (0)