wing icon indicating copy to clipboard operation
wing copied to clipboard

Cannot catch exception from inflight ctor in test

Open ShaiBer opened this issue 1 year ago • 4 comments

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 avatar Mar 14 '24 13:03 ShaiBer

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.

eladb avatar Mar 14 '24 13:03 eladb

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

staycoolcall911 avatar Mar 18 '24 14:03 staycoolcall911

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[bot] avatar Jun 17 '24 06:06 github-actions[bot]

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[bot] avatar Sep 17 '24 06:09 github-actions[bot]