Skip to content

Latest commit

 

History

History
79 lines (63 loc) · 2.5 KB

try-catch.md

File metadata and controls

79 lines (63 loc) · 2.5 KB

simple try

Open in playground

export const main = asl.deploy.asStateMachine(async () => 
 {
  try {
    lambda();
  } catch {
    return "it failed";
  }
});

simple multiple statements

Open in playground

export const main = asl.deploy.asStateMachine(async () => 
 {
  try {
    const withinTry = lambda();
    return withinTry;
  } catch {
    return "it failed";
  }
});

try around pass state

Open in playground

export const main = asl.deploy.asStateMachine(async () => 
 {
  try {
    return "this cannot fail";
  } catch {
    return "this never happens";
  }
});

try finally

Open in playground

export const main = asl.deploy.asStateMachine(async () => 
 {
  try {
    lambda();
  } finally {
    return "finally";
  }
});

try catch finally

Open in playground

export const main = asl.deploy.asStateMachine(async () => 
 {
  try {
    lambda();
  } catch {
    console.log("failed")
  } finally {
    return "finally";
  }
});