How to use the http-status-codes.INTERNAL_SERVER_ERROR function in http-status-codes

To help you get started, we’ve selected a few http-status-codes 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 Tangerine-Community / Tangerine / tree / routes / makeApk.js View on Github external
var buildIt = function(doneBuildingIt) {
    cd(`${__dirname}/../client`);
    const buildApk = exec(`npm run build:apk`);
    if (notOk(buildApk, res, HttpStatus.INTERNAL_SERVER_ERROR)) { return; }
    // Make sure the directory is there
    cd(Conf.APP_ROOT_PATH);
    console.log("APK built; moving APK, token: " + token)
    // move the apk to the right directory
    const execer = require('child_process').exec;
    execer(`mv ${Conf.APK_PATH} ${Conf.APP_ROOT_PATH}/apks/${token}`, (error, stdout, stderr) => {
      if (error) {
        console.error(`exec error: ${error}`);
        console.log(`stderr: ${stderr}`);
        return;
      }
      console.log(`stdout: ${stdout}`);
      doneBuildingIt()
    })
  }
github OliverJAsh / express-result-types / src / result.ts View on Github external
apply(content: C, writeable: Writeable): Result {
        return new Result(this.header, writeable.toEntity(content));
    }
}

// https://github.com/playframework/playframework/blob/49e1bbccdf19501f1c94732ecbef5f4f3ba0ce24/framework/src/play/src/main/scala/play/api/mvc/Results.scala#L664
export const Redirect = (url: string, statusCode: number) =>
    new Status(statusCode).withHeaders(new Map([[Header.Location, url]]));

export const TemporaryRedirect = (url: string): Result =>
    Redirect(url, HttpStatusCodes.TEMPORARY_REDIRECT);

export const Ok = new Status(HttpStatusCodes.OK);
export const BadRequest = new Status(HttpStatusCodes.BAD_REQUEST);
export const InternalServerError = new Status(HttpStatusCodes.INTERNAL_SERVER_ERROR);
github re-figure / refigure / back / metapublications.js View on Github external
`, nestTables:true}, [rec.Metapublication.ID], (err, results) => {
            if (err) {
                console.log(err);
                return cb({
                    http: httpStatus.INTERNAL_SERVER_ERROR,
                    error: constants.ERROR_SQL,
                    message: constants.ERROR_MSG_SQL
                });
            }
            rec.Metapublication.Figures = [];
            for (let r of results) {
                r.Figure.User = arrangeUserRecord(r.User);
                rec.Metapublication.Figures.push(r.Figure);
            }
            cb({data: rec});
        });
    });
github Viveckh / Veniqa / shopping-server / controllers / catalogController.js View on Github external
async searchCatalog(req, res, next) {
        let response;
        try {
            response = await catalogService.searchCatalog(req.body.pagingOptions, req.body.searchTerm, req.body.categoryIds, req.body.sortRule);
            return res.status(response.httpStatus).send(response);
        }
        catch(err) {
            logger.error("Error in searchCatalog Controller", {meta: err});
            return res.status(httpStatus.INTERNAL_SERVER_ERROR).send({httpStatus: httpStatus.INTERNAL_SERVER_ERROR, status: "failed", errorDetails: err});
        }
    },
github datash / datash / src / server / routes / api / v1 / clients.js View on Github external
res.status(HttpStatus.NOT_FOUND)
      .json({
        message: 'Recipient client not found'
      });
    return;
  }

  const toWSConns = connMap.get(toClientId);
  try {
    await shareDataViaWS(toWSConns, progressId, clientId, encKey, data);
    res.status(HttpStatus.OK)
      .json({
        message: 'shared'
      });
  } catch (err) {
    res.status(HttpStatus.INTERNAL_SERVER_ERROR)
      .json({
        message: String(err)
      });
  }
}));
github kube-HPC / hkube / core / api-server / api / rest-api / app-server.js View on Github external
rest.on('error', (data) => {
            const error = data.error || data.message || {};
            const { route, jobId, pipelineName } = (data.res && data.res._internalMetadata) || {};
            const status = data.status || data.code;
            if (status >= HttpStatus.INTERNAL_SERVER_ERROR) {
                log.error(`Error response, status=${status}, message=${error}`, { component, route, jobId, pipelineName, httpStatus: status });
            }
            else {
                log.info(`status=${status}, message=${error}`, { component, route, jobId, pipelineName, httpStatus: status });
            }
        });
github daGrevis / msks / backend / src / server / middlewares / withLogger.js View on Github external
const log = (ctx, e) => {
    const duration = new Date() - startTime

    const status = e
      ? e.status || HttpStatus.INTERNAL_SERVER_ERROR
      : ctx.status || HttpStatus.NOT_FOUND

    if (duration >= config.logger.minServerRequestDuration) {
      logger.log(
        e ? 'error' : 'verbose',
        `[server ${duration}ms] ${status}/${ctx.method} ${ctx.originalUrl}`,
      )
    }
  }
github Sunbird-Ed / SunbirdEd-portal / src / app / helpers / announcement / services / user / UserService.js View on Github external
}).catch((error) => {
        if (_.get(error, 'body.params.err') === 'USER_NOT_FOUND') {
          reject(new AppError({
            message: 'User not found',
            status: HttpStatus.NOT_FOUND
          }))
        } else if (_.get(error, 'body.params.err') === 'UNAUTHORIZE_USER') {
          reject(new AppError({
            message: 'Unauthorised user',
            status: HttpStatus.UNAUTHORIZED
          }))
        } else {
          reject(new AppError({
            message: 'Unknown error',
            status: HttpStatus.INTERNAL_SERVER_ERROR
          }))
        }
      })
    })
github Ionaru / EVIE / server / src / routers / error.router.ts View on Github external
public static errorRoute(error: Error, request: Request, response: IResponse, _next: NextFunction): void {

        response.route!.push('ErrorRouter');
        response.status(httpStatus.INTERNAL_SERVER_ERROR);

        process.stderr.write(`Error on ${request.method} ${request.originalUrl} -> ${error.stack}\n`);
        Sentry.captureException(error);

        const errorDetails = process.env.NODE_ENV === 'production' ? undefined : {error: error.stack};
        ErrorRouter.sendResponse(response, httpStatus.INTERNAL_SERVER_ERROR, 'InternalServerError', errorDetails);
    }
}
github Bikranshu / express-react-boilerplate / server / middlewares / errorHandler.js View on Github external
export function genericErrorHandler(err, req, res, next) {
    logger.error(err);
    res.status(err.status || HttpStatus.INTERNAL_SERVER_ERROR)
        .json({
            error: {
                code: err.code || HttpStatus.INTERNAL_SERVER_ERROR,
                message: err.message || HttpStatus.getStatusText(HttpStatus.INTERNAL_SERVER_ERROR)
            }
        });
}