Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add global exception catching #1256

Open
1 task
wamynobe opened this issue Jan 21, 2024 · 6 comments
Open
1 task

feat: add global exception catching #1256

wamynobe opened this issue Jan 21, 2024 · 6 comments
Labels
feature A new feature or request p3 Issues that we currently consider unimportant

Comments

@wamynobe
Copy link

Description

Clearly describe what you are looking to add. The more context the better.

Requirements

  • Checklist of requirements to be fulfilled

Additional Context

Add any other context or screenshots about the feature request go here.

@alestiago
Copy link
Contributor

alestiago commented Feb 6, 2024

Hi @wamynobe 👋 ! I'm curious to know if you have a proposal on how this should be done 👀, for example, do you have an API in mind?

@wamynobe
Copy link
Author

wamynobe commented Feb 6, 2024

Hi @alestiago . I have some ideals.

void main() async {
  entrypoint.bootstrap(
    () async {
      final address = InternetAddress.tryParse('{{{host}}}') ?? InternetAddress.anyIPv6;
      final port = int.tryParse(Platform.environment['PORT'] ?? '{{{port}}}') ?? {{{port}}};{{#invokeCustomInit}}
      await entrypoint.init(address, port);{{/invokeCustomInit}}
      hotReload(() => createServer(address, port));
    }
  );
  
}

Can we add a bootstrap function in custom main file?
This may help in some cases like using third-party SDK in order to log errors on my server.
Then we can go like

void bootstrap(void Function() callback) async{
  runZonedGuarded(
    () => callback.call(),
    (error, stack) {
      // I want to log the error here
      log('Error: $error');
    },
  );
}

Or if you want to use SentrySDK for dart you can go like

void bootstrap(void Function() callback) async{
   await Sentry.init(
    (options) {
      options.dsn = 'https://[email protected]/example';
    },
    appRunner: callback,
  );
}

That's all!
I'm new here so please forgive me if I've said anything wrong ^_^.

@wamynobe
Copy link
Author

wamynobe commented Feb 6, 2024

I am trying to figure out how to use Mason and how to customize these bricks. I want to check my ideal but I have not found a way to custom dart_frog_dev_server yet.

@wamynobe
Copy link
Author

wamynobe commented Feb 7, 2024

I checked dart_frog_dev_server brick but I have no ideal how to modify this file because of the line "// GENERATED CODE - DO NOT MODIFY BY HAND". I'm confused!

@alestiago
Copy link
Contributor

alestiago commented Feb 7, 2024

@wamynobe thank you for taking an initiative here 💙 .

There is a CONTRIBUTING guide for updating Dart Frog CLI. There is no CONTRIBUTING guide for the bricks. I think we should have one. I may be able to provide one, however, you might have to bear with me, since I have other tasks with greater priority.

In terms of moving forward and adding global exception catching, it needs to be discussed with the team and evaluated. In the meantime, if you would like to work on a proof of concept, please do!

@wamynobe
Copy link
Author

wamynobe commented Feb 8, 2024

@alestiago Thank you for the instructions. I can now edit the server.dart file and it works as I expected. Thanks for pointing out the contribute section in the cli. I honestly overlooked it when trying to modify bricks and bundles. Regarding this issue, after discussing with the team, if there is anything I can help with, please ask!

@tomarra tomarra moved this from Needs Triage to Backlog in VGV Open Source 🦄 🧙🌟 Aug 30, 2024
@tomarra tomarra added feature A new feature or request p3 Issues that we currently consider unimportant labels Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature or request p3 Issues that we currently consider unimportant
Projects
Status: Backlog
Development

No branches or pull requests

3 participants