Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions components/error/actions/throw-error/throw-error.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import error from "../../error.app.mjs";

export default {
name: "Throw Error",
version: "0.0.1",
key: "error-throw-error",
description: "Quickly throw an error from your workflow.",
props: {
error,
name: {
propDefinition: [
error,
"name",
],
},
errorMessage: {
propDefinition: [
error,
"errorMessage",
],
},
},
type: "action",
async run() {
this.error.maybeCreateAndThrowError(this.name, this.errorMessage);
},
};
40 changes: 35 additions & 5 deletions components/error/error.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
export default {
type: "app",
app: "error",
propDefinitions: {},
propDefinitions: {
name: {
type: "string",
label: "Error Name",
description:
"The **name** (class) of error to throw, which you can define as any custom string. This will show up in all of the standard Pipedream error handling destinations.",
default: "Error",
},
errorMessage: {
type: "string",
label: "Error Message",
description:
"The error **message** to throw. This will show up in all of the standard Pipedream error handling destinations.",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
maybeCreateAndThrowError(name, message) {
const errorClass = global[name];

// Check if the error class exists and is a subclass of Error
if (
typeof errorClass === "function" &&
errorClass.prototype.isPrototypeOf.call(Error)
) {
throw new errorClass(message);
}

class DynamicError extends Error {
constructor(msg) {
super(msg);
this.name = name;
}
}
throw new DynamicError(message);
},
},
};
};
4 changes: 2 additions & 2 deletions components/error/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/error",
"version": "0.0.1",
"version": "0.0.2",
"description": "Pipedream Error Components",
"main": "error.app.mjs",
"keywords": [
Expand All @@ -12,4 +12,4 @@
"publishConfig": {
"access": "public"
}
}
}
Loading