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

Cannot catch exception from inflight ctor in test #5948

Open
ShaiBer opened this issue Mar 14, 2024 · 4 comments
Open

Cannot catch exception from inflight ctor in test #5948

ShaiBer opened this issue Mar 14, 2024 · 4 comments
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler

Comments

@ShaiBer
Copy link
Contributor

ShaiBer commented Mar 14, 2024

I tried this:

pub class InflightThrower {
  pub inflight operation () {
    throw "Exception from inflight operation";
  }
}

pub class InflightConstructorThrower {
    inflight new () {
    throw "Exception from inflight constructor";
  }

  pub inflight operation () {}
}

let constructoThrower = new InflightConstructorThrower();
let opThrower = new InflightThrower();

test "catch exception from test code" {
  try {
    throw "Weee";
  } catch e {}
}

test "catch exception in test from inflight op" {
  try {
    opThrower.operation();
  } catch e {}
}

test "catch exception in test from inflight ctor" {
  try {
    constructoThrower.operation();
  } catch e {}
}

This happened:

First 2 tests passed, 3rd one failed (catch exception in test from inflight ctor)

I expected this:

All 3 tests to pass

Is there a workaround?

Not that I could find..

Anything else?

No response

Wing Version

0.61.1

Node.js Version

No response

Platform(s)

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@ShaiBer ShaiBer added 🐛 bug Something isn't working 🛠️ compiler Compiler labels Mar 14, 2024
@monadabot monadabot added this to Wing Mar 14, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Mar 14, 2024
@eladb
Copy link
Contributor

eladb commented Mar 14, 2024

Yes, that's a good point, but I am not sure if there's a reasonable way to support this. The inflight constructor is invoked implicitly (and only once) per runtime environment (e.g. cloud.Function), so I am not sure how users would express their intent to catch exceptions there.

Can you share some details about the use case? Maybe there's a way to achieve it without having to catch inflight constructor exceptions.

@staycoolcall911
Copy link
Contributor

@eladb - he was trying to test a winglib in this PR (see the commented test in openai/openai.test.w).

@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Mar 20, 2024
Copy link

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

Copy link

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Sep 17, 2024
@Chriscbr Chriscbr removed the Stale label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

4 participants