sonikjs / sonik

349 stars 9 forks source link

_error.tsx doesn't render body content. #7

Closed bruceharrison1984 closed 8 months ago

bruceharrison1984 commented 1 year ago

For an error handler such as this:

// app/_error.tsx
const errorHandler: ErrorHandler = (ctx, { error, head }) => {
  head.title = 'Exception';

  return ctx.render(
    <GlobalErrorPage
      error="Unknown error"
      message="An unknown error has occured. Please try again later."
    />
  );
};

export default errorHandler;

The page that is returned contains only the _layout.tsx content, and an empty body tag.

bruceharrison1984 commented 1 year ago

Just found my answer in the tests: https://github.com/yusukebe/sonik/blob/main/packages/sonik/test/hono-jsx/app/routes/_error.tsx

Might want to flesh out the docs a bit here, since it is currently missing entirely. I assumed I could return via context.render, but the _error.tsx page just wants JSX returned directly.

yusukebe commented 1 year ago

Hi @bruceharrison1984 !

Thank you for using Sonik! Please note that Sonik is still in Dev phase as you know, so there are some incomplete things.

This is either a bug or unimplemented; ErrorHandler should also be able to return a Response. I'll try to implement it later.