-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: error support in render, debugger, example
- Loading branch information
1 parent
54abae4
commit 7c74f35
Showing
13 changed files
with
178 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@frames.js/debugger": patch | ||
"@frames.js/render": patch | ||
--- | ||
|
||
feat: frame error message support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"framesjs-starter": patch | ||
--- | ||
|
||
feat: error example |
5 changes: 5 additions & 0 deletions
5
examples/framesjs-starter/app/examples/new-api-error/frames/frames.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { createFrames } from "frames.js/next"; | ||
|
||
export const frames = createFrames({ | ||
basePath: "/examples/new-api-error/frames", | ||
}); |
29 changes: 29 additions & 0 deletions
29
examples/framesjs-starter/app/examples/new-api-error/frames/route.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable react/jsx-key */ | ||
import { Button } from "frames.js/next"; | ||
import { frames } from "./frames"; | ||
import { error } from "frames.js/core"; | ||
|
||
const handler = frames(async (ctx) => { | ||
if (ctx.message) { | ||
if (!ctx.message.inputText) { | ||
console.log("error"); | ||
error("Invalid input: Empty text"); | ||
} | ||
} | ||
|
||
return { | ||
image: ctx.message?.inputText ? ( | ||
<div tw="flex">Entered text: {ctx.message.inputText}</div> | ||
) : ( | ||
<div tw="flex flex-col"> | ||
<div tw="flex">Enter text</div> | ||
<div tw="flex">Empty text input will throw an error</div> | ||
</div> | ||
), | ||
textInput: "Enter text or leave empty", | ||
buttons: [<Button action="post">Enter</Button>], | ||
}; | ||
}); | ||
|
||
export const GET = handler; | ||
export const POST = handler; |
33 changes: 33 additions & 0 deletions
33
examples/framesjs-starter/app/examples/new-api-error/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Link from "next/link"; | ||
import { currentURL, vercelURL } from "../../utils"; | ||
import { createDebugUrl } from "../../debug"; | ||
import type { Metadata } from "next"; | ||
import { fetchMetadata } from "frames.js/next"; | ||
|
||
export async function generateMetadata(): Promise<Metadata> { | ||
return { | ||
title: "New api example", | ||
description: "This is a new api example", | ||
other: { | ||
...(await fetchMetadata( | ||
new URL( | ||
"/examples/new-api-error/frames", | ||
vercelURL() || "http://localhost:3000" | ||
) | ||
)), | ||
}, | ||
}; | ||
} | ||
|
||
export default async function Home() { | ||
const url = currentURL("/examples/new-api-error"); | ||
|
||
return ( | ||
<div> | ||
New api error example.{" "} | ||
<Link href={createDebugUrl(url)} className="underline"> | ||
Debug | ||
</Link> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class PresentableError extends Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters