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

@ -1,5 +1,5 @@
module.exports = () => {
const hiddenSubtreeService = require('../../src/services/hidden_subtree.js');
const hiddenSubtreeService = require('../../src/services/hidden_subtree');
const cls = require("../../src/services/cls");
const beccaLoader = require("../../src/becca/becca_loader");

View file

@ -2,7 +2,7 @@
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const dumpService = require("./inc/dump.js");
const dumpService = require("./inc/dump");
yargs(hideBin(process.argv))
.command('$0 <path_to_document> <target_directory>', 'dump the contents of document.db into the target directory', (yargs) => {

View file

@ -1,6 +1,6 @@
const crypto = require("crypto");
const sql = require("./sql.js");
const decryptService = require("./decrypt.js");
const sql = require("./sql");
const decryptService = require("./decrypt");
function getDataKey(password) {
if (!password) {

View file

@ -1,9 +1,9 @@
const fs = require("fs");
const sanitize = require("sanitize-filename");
const sql = require("./sql.js");
const decryptService = require("./decrypt.js");
const dataKeyService = require("./data_key.js");
const extensionService = require("./extension.js");
const sql = require("./sql");
const decryptService = require("./decrypt");
const dataKeyService = require("./data_key");
const extensionService = require("./extension");
function dumpDocument(documentPath, targetPath, options) {
const stats = {

View file

@ -4,7 +4,7 @@ const Branch = require('../../src/becca/entities/branch');
const SearchContext = require('../../src/services/search/search_context');
const dateUtils = require('../../src/services/date_utils');
const becca = require('../../src/becca/becca');
const {NoteBuilder, findNoteByTitle, note} = require('./becca_mocking.js');
const {NoteBuilder, findNoteByTitle, note} = require('./becca_mocking');
describe("Search", () => {
let rootNote;

View file

@ -1,4 +1,4 @@
const {note} = require('./becca_mocking.js');
const {note} = require('./becca_mocking');
const ValueExtractor = require('../../src/services/search/value_extractor');
const becca = require('../../src/becca/becca');
const SearchContext = require("../../src/services/search/search_context");

View file

@ -1,6 +1,6 @@
"use strict";
const becca = require('./becca.js');
const becca = require('./becca');
const cls = require('../services/cls');
const protectedSessionService = require('../services/protected_session');
const log = require('../services/log');

View file

@ -4,7 +4,7 @@ const Note = require('./note');
const AbstractEntity = require("./abstract_entity");
const sql = require("../../services/sql");
const dateUtils = require("../../services/date_utils");
const utils = require("../../services/utils.js");
const utils = require("../../services/utils");
const TaskContext = require("../../services/task_context");
const cls = require("../../services/cls");
const log = require("../../services/log");

View file

@ -1,6 +1,6 @@
const becca = require('./becca');
const log = require('../services/log');
const beccaService = require('./becca_service.js');
const beccaService = require('./becca_service');
const dateUtils = require('../services/date_utils');
const { JSDOM } = require("jsdom");

View file

@ -1,5 +1,5 @@
const appInfo = require('../services/app_info');
const eu = require("./etapi_utils.js");
const eu = require("./etapi_utils");
function register(router) {
eu.route(router, 'get', '/etapi/app-info', (req, res, next) => {

View file

@ -357,7 +357,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {
// disable spellcheck for attribute editor
this.textEditor.editing.view.change(writer => writer.setAttribute('spellcheck', 'false', this.textEditor.editing.view.document.getRoot()));
//await import(/* webpackIgnore: true */'../../libraries/ckeditor/inspector.js');
//await import(/* webpackIgnore: true */'../../libraries/ckeditor/inspector');
//CKEditorInspector.attach(this.textEditor);
}

View file

@ -452,7 +452,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
const files = [...dataTransfer.files]; // chrome has issue that dataTransfer.files empties after async operation
const importService = await import('../services/import.js');
const importService = await import('../services/import');
importService.uploadFiles(node.data.noteId, files, {
safeImport: true,

View file

@ -132,7 +132,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
this.textEditor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
if (glob.isDev && ENABLE_INSPECTOR) {
await import(/* webpackIgnore: true */'../../../libraries/ckeditor/inspector.js');
await import(/* webpackIgnore: true */'../../../libraries/ckeditor/inspector');
CKEditorInspector.attach(this.textEditor);
}
}

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);

View file

@ -6,7 +6,7 @@ const myScryptService = require('../services/my_scrypt');
const log = require('../services/log');
const passwordService = require("../services/password");
const assetPath = require("../services/asset_path");
const ValidationError = require("../public/app/services/validation_error.js");
const ValidationError = require("../errors/validation_error");
function loginPage(req, res) {
res.render('login', {

View file

@ -5,7 +5,7 @@ const loginRoute = require('./login');
const indexRoute = require('./index');
const utils = require('../services/utils');
const multer = require('multer');
const ValidationError = require("../errors/validation_error.js");
const ValidationError = require("../errors/validation_error");
// API routes
const treeApiRoute = require('./api/tree');
@ -62,7 +62,7 @@ const csurf = require('csurf');
const {createPartialContentHandler} = require("express-partial-content");
const rateLimit = require("express-rate-limit");
const AbstractEntity = require("../becca/entities/abstract_entity");
const NotFoundError = require("../errors/not_found_error.js");
const NotFoundError = require("../errors/not_found_error");
const csrfMiddleware = csurf({
cookie: true,

View file

@ -1,6 +1,6 @@
const becca = require("../becca/becca");
const noteService = require("./notes");
const log = require("./log.js");
const log = require("./log");
const LBTPL_ROOT = "lbTplRoot";
const LBTPL_BASE = "lbTplBase";

View file

@ -18,8 +18,8 @@ const Branch = require('../becca/entities/branch');
const Note = require('../becca/entities/note');
const Attribute = require('../becca/entities/attribute');
const dayjs = require("dayjs");
const htmlSanitizer = require("./html_sanitizer.js");
const ValidationError = require("../errors/validation_error.js");
const htmlSanitizer = require("./html_sanitizer");
const ValidationError = require("../errors/validation_error");
function getNewNotePosition(parentNoteId) {
const note = becca.notes[parentNoteId];

View file

@ -12,7 +12,7 @@ const PropertyComparisonExp = require('../expressions/property_comparison');
const AttributeExistsExp = require('../expressions/attribute_exists');
const LabelComparisonExp = require('../expressions/label_comparison');
const NoteFlatTextExp = require('../expressions/note_flat_text');
const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js');
const NoteContentFulltextExp = require('../expressions/note_content_fulltext');
const OrderByAndLimitExp = require('../expressions/order_by_and_limit');
const AncestorExp = require("../expressions/ancestor");
const buildComparator = require('./build_comparator');

View file

@ -10,7 +10,7 @@ const becca = require('../../../becca/becca');
const beccaService = require('../../../becca/becca_service');
const utils = require('../../utils');
const log = require('../../log');
const scriptService = require("../../script.js");
const scriptService = require("../../script");
function searchFromNote(note) {
let searchResultNoteIds, highlightedTokens;

View file

@ -4,7 +4,7 @@ const becca = require("../becca/becca");
const noteService = require("./notes");
const cls = require("./cls");
const dateUtils = require("./date_utils");
const log = require("./log.js");
const log = require("./log");
const hiddenSubtreeService = require("./hidden_subtree");
function getInboxNote(date) {