introduced new exception classes for structured error reporting

This commit is contained in:
zadam
2022-12-09 16:13:22 +01:00
parent 342ae6e5e2
commit dfb462cf35
35 changed files with 48 additions and 49 deletions

View File

@@ -5,8 +5,8 @@ const log = require('../../services/log');
const attributeService = require('../../services/attributes');
const Attribute = require('../../becca/entities/attribute');
const becca = require("../../becca/becca");
const ValidationError = require("../../public/app/services/validation_error.js");
const NotFoundError = require("../../errors/not_found_error.js");
const ValidationError = require("../../errors/validation_error");
const NotFoundError = require("../../errors/not_found_error");
function getEffectiveNoteAttributes(req) {
const note = becca.getNote(req.params.noteId);

View File

@@ -8,9 +8,9 @@ const noteService = require('../../services/notes');
const becca = require('../../becca/becca');
const TaskContext = require('../../services/task_context');
const branchService = require("../../services/branches");
const log = require("../../services/log.js");
const ValidationError = require("../../public/app/services/validation_error.js");
const NotFoundError = require("../../errors/not_found_error.js");
const log = require("../../services/log");
const ValidationError = require("../../errors/validation_error");
const NotFoundError = require("../../errors/not_found_error");
/**
* Code in this file deals with moving and cloning branches. Relationship between note and parent note is unique

View File

@@ -6,7 +6,7 @@ const opmlExportService = require('../../services/export/opml');
const becca = require('../../becca/becca');
const TaskContext = require("../../services/task_context");
const log = require("../../services/log");
const NotFoundError = require("../../errors/not_found_error.js");
const NotFoundError = require("../../errors/not_found_error");
function exportBranch(req, res) {
const {branchId, type, format, version, taskId} = req.params;

View File

@@ -10,7 +10,7 @@ const { Readable } = require('stream');
const chokidar = require('chokidar');
const ws = require('../../services/ws');
const becca = require("../../becca/becca");
const NotFoundError = require("../../errors/not_found_error.js");
const NotFoundError = require("../../errors/not_found_error");
function updateFile(req) {
const {noteId} = req.params;

View File

@@ -4,8 +4,8 @@ const imageService = require('../../services/image');
const becca = require('../../becca/becca');
const RESOURCE_DIR = require('../../services/resource_dir').RESOURCE_DIR;
const fs = require('fs');
const ValidationError = require("../../public/app/services/validation_error.js");
const NotFoundError = require("../../errors/not_found_error.js");
const ValidationError = require("../../errors/validation_error");
const NotFoundError = require("../../errors/not_found_error");
function returnImage(req, res) {
const image = becca.getNote(req.params.noteId);

View File

@@ -10,8 +10,8 @@ const becca = require('../../becca/becca');
const beccaLoader = require('../../becca/becca_loader');
const log = require('../../services/log');
const TaskContext = require('../../services/task_context');
const ValidationError = require("../../public/app/services/validation_error.js");
const NotFoundError = require("../../errors/not_found_error.js");
const ValidationError = require("../../errors/validation_error");
const NotFoundError = require("../../errors/not_found_error");
async function importToBranch(req) {
const {parentNoteId} = req.params;

View File

@@ -2,7 +2,7 @@
const becca = require("../../becca/becca");
const { JSDOM } = require("jsdom");
const NotFoundError = require("../../errors/not_found_error.js");
const NotFoundError = require("../../errors/not_found_error");
function buildDescendantCountMap() {
const noteIdToCountMap = {};

View File

@@ -6,11 +6,10 @@ const sql = require('../../services/sql');
const utils = require('../../services/utils');
const log = require('../../services/log');
const TaskContext = require('../../services/task_context');
const protectedSessionService = require('../../services/protected_session');
const fs = require('fs');
const becca = require("../../becca/becca");
const ValidationError = require("../../public/app/services/validation_error.js");
const NotFoundError = require("../../errors/not_found_error.js");
const ValidationError = require("../../errors/validation_error");
const NotFoundError = require("../../errors/not_found_error");
function getNote(req) {
const noteId = req.params.noteId;

View File

@@ -3,7 +3,7 @@
const optionService = require('../../services/options');
const log = require('../../services/log');
const searchService = require('../../services/search/services/search');
const ValidationError = require("../../public/app/services/validation_error.js");
const ValidationError = require("../../errors/validation_error");
// options allowed to be updated directly in options dialog
const ALLOWED_OPTIONS = new Set([

View File

@@ -1,7 +1,7 @@
"use strict";
const passwordService = require('../../services/password');
const ValidationError = require("../../public/app/services/validation_error.js");
const ValidationError = require("../../errors/validation_error");
function changePassword(req) {
if (passwordService.isPasswordSet()) {

View File

@@ -6,8 +6,8 @@ const searchService = require('../../services/search/services/search');
const bulkActionService = require("../../services/bulk_actions");
const cls = require("../../services/cls");
const {formatAttrForSearch} = require("../../services/attribute_formatter");
const ValidationError = require("../../public/app/services/validation_error.js");
const NotFoundError = require("../../errors/not_found_error.js");
const ValidationError = require("../../errors/validation_error");
const NotFoundError = require("../../errors/not_found_error");
function searchFromNote(req) {
const note = becca.getNote(req.params.noteId);

View File

@@ -2,7 +2,7 @@
const similarityService = require('../../becca/similarity');
const becca = require("../../becca/becca");
const NotFoundError = require("../../errors/not_found_error.js");
const NotFoundError = require("../../errors/not_found_error");
async function getSimilarNotes(req) {
const noteId = req.params.noteId;

View File

@@ -2,7 +2,7 @@
const sql = require('../../services/sql');
const becca = require("../../becca/becca");
const NotFoundError = require("../../errors/not_found_error.js");
const NotFoundError = require("../../errors/not_found_error");
function getSchema() {
const tableNames = sql.getColumn(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`);

View File

@@ -1,6 +1,6 @@
const sql = require('../../services/sql');
const becca = require('../../becca/becca');
const NotFoundError = require("../../errors/not_found_error.js");
const NotFoundError = require("../../errors/not_found_error");
function getNoteSize(req) {
const {noteId} = req.params;

View File

@@ -2,7 +2,7 @@
const becca = require('../../becca/becca');
const log = require('../../services/log');
const NotFoundError = require("../../errors/not_found_error.js");
const NotFoundError = require("../../errors/not_found_error");
function getNotesAndBranchesAndAttributes(noteIds) {
noteIds = new Set(noteIds);