How to use the moleculer.MoleculerServerError function in moleculer

To help you get started, we’ve selected a few moleculer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github icebob / kantab / backend / mixins / openapi.mixin.js View on Github external
method = p[0].toLowerCase();
										routePath = p[1];
										delete def.$path;
									}

									_.set(res.paths, [routePath, method], def);
								}
							}
						});

					});

					return res;

				} catch(err) {
					throw new MoleculerServerError("Unable to compile OpenAPI schema", 500, "UNABLE_COMPILE_OPENAPI_SCHEMA", { err });
				}
			}
		},
github moleculerjs / moleculer-web / src / index.js View on Github external
if (route.logging)
					this.logger.info(`   Call custom function in '${alias.toString()}' alias`);

				await new this.Promise((resolve, reject) => {
					alias.handler.call(this, req, res, err => {
						if (err)
							reject(err);
						else
							resolve();
					});
				});

				if (alias.action)
					return this.callAction(route, alias.action, req, res, alias.type == "stream" ? req : req.$params);
				else
					throw new MoleculerServerError("No alias handler", 500, "NO_ALIAS_HANDLER", { path: req.originalUrl, alias: _.pick(alias, ["method", "path"]) });

			} else if (alias.action) {
				return this.callAction(route, alias.action, req, res, alias.type == "stream" ? req : req.$params);
			}
		},
github icebob / kantab / backend / mixins / graphql.mixin.js View on Github external
if (mutations.length > 0) {
							str += `
								type Mutation {
									${mutations.join("\n")}
								}
							`;
						}

						typeDefs.push(str);
					}

					return makeExecutableSchema({ typeDefs, resolvers });

				} catch(err) {
					throw new MoleculerServerError("Unable to compile GraphQL schema", 500, "UNABLE_COMPILE_GRAPHQL_SCHEMA", { err });
				}
			}
		},
github moleculerjs / moleculer-apollo-server / src / service.js View on Github external
${enums.join("\n")}
							`;
						}

						if (inputs.length > 0) {
							str += `
								${inputs.join("\n")}
							`;
						}

						typeDefs.push(str);
					}

					return makeExecutableSchema({ typeDefs, resolvers, schemaDirectives });
				} catch (err) {
					throw new MoleculerServerError(
						"Unable to compile GraphQL schema",
						500,
						"UNABLE_COMPILE_GRAPHQL_SCHEMA",
						{ err }
					);
				}
			},