riccardoperra / codeimage

A tool to beautify your code screenshots. Built with SolidJS and Fastify.
https://codeimage.dev
MIT License
1.39k stars 73 forks source link

feat(api): core custom error handling #481

Closed riccardoperra closed 1 year ago

riccardoperra commented 1 year ago

Add custom error handling to api module

Create custom errors

class PresetNotFoundException extends NotFoundEntityException<{id: string}> { 
  createMessage(args: { id: string }) {
    return `Preset with id ${id} not found`
  }
}

Then in your handler

async findById(id: string) { 
  const preset = ...
  if (!preset) { 
    throw new PresetNotFoundException({ id })
  }
}
codesandbox[bot] commented 1 year ago

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

changeset-bot[bot] commented 1 year ago

⚠️ No Changeset found

Latest commit: a1ec9749d87b5c27965d213380665eb6874873da

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

github-actions[bot] commented 1 year ago

Deploy preview for codeimage-ui-dev ready!

✅ Preview https://codeimage-ui-dv9r5mvnk-riccardoperra.vercel.app https://codeimage-ui-pr-481.vercel.app

Built with commit a1ec9749d87b5c27965d213380665eb6874873da. This pull request is being automatically deployed with vercel-action

github-actions[bot] commented 1 year ago

Deploy preview for codeimage-highlight-dev ready!

✅ Preview https://codeimage-highlight-ak0gjexq3-riccardoperra.vercel.app https://codeimage-highlight-pr-481.vercel.app

Built with commit a1ec9749d87b5c27965d213380665eb6874873da. This pull request is being automatically deployed with vercel-action

github-actions[bot] commented 1 year ago

Deploy preview for codeimage-website-dev ready!

✅ Preview https://codeimage-website-rlgguy93b-riccardoperra.vercel.app https://codeimage-website-pr-481.vercel.app

Built with commit a1ec9749d87b5c27965d213380665eb6874873da. This pull request is being automatically deployed with vercel-action

github-actions[bot] commented 1 year ago

Deploy preview for codeimage ready!

✅ Preview https://codeimage-7yobnxuu4-riccardoperra.vercel.app https://codeimage-app-pr-481.vercel.app

Built with commit a1ec9749d87b5c27965d213380665eb6874873da. This pull request is being automatically deployed with vercel-action

riccardoperra commented 1 year ago

Already present in next branch