winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.98k stars 196 forks source link

Cannot catch exception from inflight ctor in test #5948

Open ShaiBer opened 6 months ago

ShaiBer commented 6 months ago

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

eladb commented 6 months ago

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 commented 6 months ago

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

github-actions[bot] commented 3 months ago

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] commented 2 weeks ago

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!