@remix-run/router 1.0.3 → 1.0.4-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/utils.ts CHANGED
@@ -41,6 +41,7 @@ export interface RedirectResult {
41
41
  status: number;
42
42
  location: string;
43
43
  revalidate: boolean;
44
+ external: boolean;
44
45
  }
45
46
 
46
47
  /**
@@ -61,7 +62,9 @@ export type DataResult =
61
62
  | RedirectResult
62
63
  | ErrorResult;
63
64
 
64
- export type FormMethod = "get" | "post" | "put" | "patch" | "delete";
65
+ export type SubmissionFormMethod = "post" | "put" | "patch" | "delete";
66
+ export type FormMethod = "get" | SubmissionFormMethod;
67
+
65
68
  export type FormEncType =
66
69
  | "application/x-www-form-urlencoded"
67
70
  | "multipart/form-data";
@@ -72,7 +75,7 @@ export type FormEncType =
72
75
  * external consumption
73
76
  */
74
77
  export interface Submission {
75
- formMethod: Exclude<FormMethod, "get">;
78
+ formMethod: SubmissionFormMethod;
76
79
  formAction: string;
77
80
  formEncType: FormEncType;
78
81
  formData: FormData;
@@ -1243,11 +1246,24 @@ export class ErrorResponse {
1243
1246
  status: number;
1244
1247
  statusText: string;
1245
1248
  data: any;
1246
-
1247
- constructor(status: number, statusText: string | undefined, data: any) {
1249
+ error?: Error;
1250
+ internal: boolean;
1251
+
1252
+ constructor(
1253
+ status: number,
1254
+ statusText: string | undefined,
1255
+ data: any,
1256
+ internal = false
1257
+ ) {
1248
1258
  this.status = status;
1249
1259
  this.statusText = statusText || "";
1250
- this.data = data;
1260
+ this.internal = internal;
1261
+ if (data instanceof Error) {
1262
+ this.data = data.toString();
1263
+ this.error = data;
1264
+ } else {
1265
+ this.data = data;
1266
+ }
1251
1267
  }
1252
1268
  }
1253
1269