File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import type {
1313 PublishVersionInput ,
1414 Version ,
1515} from "../types" ;
16- import { wrapAction } from "../wrap-action " ;
16+ import { wrapAction } from "../utils " ;
1717
1818function assertNotArchived ( doc : { archivedAt : Date | null } ) : void {
1919 if ( doc . archivedAt !== null ) {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import type {
99 DeleteMediaInput ,
1010 RenameInput ,
1111} from "../types" ;
12- import { wrapAction } from "../wrap-action " ;
12+ import { wrapAction } from "../utils " ;
1313
1414export async function uploadMediaAction (
1515 formData : FormData
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import type {
77 DeleteRouteInput ,
88 UpdateRouteInput ,
99} from "../types" ;
10- import { wrapAction } from "../wrap-action " ;
10+ import { wrapAction } from "../utils " ;
1111
1212const ROUTE_SEGMENT_RE = / ^ [ a - z 0 - 9 _ - ] + $ / ;
1313
Original file line number Diff line number Diff line change 11import { clsx , type ClassValue } from "clsx"
22import { twMerge } from "tailwind-merge"
3+ import type { ActionResult } from "./types" ;
34
45export function cn ( ...inputs : ClassValue [ ] ) {
56 return twMerge ( clsx ( inputs ) )
@@ -12,3 +13,16 @@ export function validateName(name: string): string {
1213 }
1314 return trimmed ;
1415}
16+
17+ export async function wrapAction < T > (
18+ fn : ( ) => Promise < T >
19+ ) : Promise < ActionResult < T > > {
20+ try {
21+ return { success : true , data : await fn ( ) } ;
22+ } catch ( error ) {
23+ return {
24+ success : false ,
25+ error : error instanceof Error ? error . message : "Unknown error" ,
26+ } ;
27+ }
28+ }
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments