{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interrupt error is an internal error thrown by flow states to interrupt execution of the step.\n */\nexport class InterruptError extends Error {}\n\n/**\n * Extracts error message from the given error object, or if input is not an error then just turn the error into a string.\n */\nexport function getErrorMessage(e: any): string {\n  if (e instanceof Error) {\n    return e.message;\n  }\n  return `${e}`;\n}\n\n/**\n * Extracts stack trace from the given error object, or if input is not an error then returns undefined.\n */\nexport function getErrorStack(e: any): string | undefined {\n  if (e instanceof Error) {\n    return e.stack;\n  }\n  return undefined;\n}\n\n/**\n * Exception thrown when flow is not found in the flow state store.\n */\nexport class FlowNotFoundError extends Error {\n  constructor(msg: string) {\n    super(msg);\n  }\n}\n\n/**\n * Exception thrown when flow execution is not completed yet.\n */\nexport class FlowStillRunningError extends Error {\n  constructor(readonly flowId: string) {\n    super(\n      `flow ${flowId} is not done execution. Consider using waitForFlowToComplete to wait for ` +\n        'completion before calling getOutput.'\n    );\n  }\n}\n\n/**\n * Exception thrown when flow execution resulted in an error.\n */\nexport class FlowExecutionError extends Error {\n  constructor(\n    readonly flowId: string,\n    readonly originalMessage: string,\n    readonly originalStacktrace?: any\n  ) {\n    super(originalMessage);\n    this.stack = originalStacktrace;\n  }\n}\n"],"mappings":";AAmBO,MAAM,uBAAuB,MAAM;AAAC;AAKpC,SAAS,gBAAgB,GAAgB;AAC9C,MAAI,aAAa,OAAO;AACtB,WAAO,EAAE;AAAA,EACX;AACA,SAAO,GAAG,CAAC;AACb;AAKO,SAAS,cAAc,GAA4B;AACxD,MAAI,aAAa,OAAO;AACtB,WAAO,EAAE;AAAA,EACX;AACA,SAAO;AACT;AAKO,MAAM,0BAA0B,MAAM;AAAA,EAC3C,YAAY,KAAa;AACvB,UAAM,GAAG;AAAA,EACX;AACF;AAKO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAqB,QAAgB;AACnC;AAAA,MACE,QAAQ,MAAM;AAAA,IAEhB;AAJmB;AAAA,EAKrB;AACF;AAKO,MAAM,2BAA2B,MAAM;AAAA,EAC5C,YACW,QACA,iBACA,oBACT;AACA,UAAM,eAAe;AAJZ;AACA;AACA;AAGT,SAAK,QAAQ;AAAA,EACf;AACF;","names":[]}