Skip to content

Commit

Permalink
replace logError with console.error() (#592)
Browse files Browse the repository at this point in the history
Co-authored-by: Sonny Piers <[email protected]>
  • Loading branch information
SoNiC-HeRE and sonnyp authored Sep 17, 2023
1 parent 5f542ff commit 51d6aa0
Show file tree
Hide file tree
Showing 49 changed files with 90 additions and 91 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/lib
troll
flatpak
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ rules:
no-duplicate-imports: [error] # https://eslint.org/docs/latest/rules/no-duplicate-imports
no-new-native-nonconstructor: [error] # https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
# TODO: log and logError
no-restricted-globals: [error, window, printerr, print, imports] # https://eslint.org/docs/rules/no-restricted-globals
no-restricted-globals: [error, window, printerr, print, imports, logError] # https://eslint.org/docs/rules/no-restricted-globals
no-unused-vars: # https://eslint.org/docs/latest/rules/no-unused-vars
- error
- vars: all
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"lint-staged": {
"*.{css,json,md,yaml,yml}": "prettier --write",
"*.{js,cjs,mjs}": "eslint --fix",
"*.rs": "flatpak run --user --command=/usr/lib/sdk/rust-stable/bin/rustfmt --filesystem=host:ro org.gnome.Sdk//45beta --edition 2021"
"*.rs": "flatpak run --user --command=/usr/lib/sdk/rust-stable/bin/rustfmt --filesystem=host org.gnome.Sdk//45beta --edition 2021"
}
}
4 changes: 2 additions & 2 deletions src/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export default function Document({ session, code_view, file, lang }) {

function save() {
saveSourceBuffer({ source_file, buffer })
.catch(logError)
.catch(console.error)
.finally(() => {
try {
session.settings.set_boolean("edited", true);
} catch (err) {
logError(err);
console.error(err);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Library({ application }) {
widget.connect("activated", () => {
last_selected = widget;

openDemo({ application, demo_name: demo.name }).catch(logError);
openDemo({ application, demo_name: demo.name }).catch(console.error);
});

builder.get_object(`library_${demo.category}`).add(widget);
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Account/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ async function onClicked() {
}

button.connect("clicked", () => {
onClicked().catch(logError);
onClicked().catch(console.error);
});
2 changes: 1 addition & 1 deletion src/Library/demos/Avatar/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const dialog = new Gtk.FileDialog({
});

button.connect("clicked", () => {
onClicked().catch(logError);
onClicked().catch(console.error);
});

async function onClicked() {
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Camera/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const output = workbench.builder.get_object("output");
const button = workbench.builder.get_object("button");

button.connect("clicked", () => {
accessCamera().catch(logError);
accessCamera().catch(console.error);
});

async function accessCamera() {
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Color Dialog/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const dialog_custom = new Gtk.ColorDialog({
});

custom_button.connect("clicked", () => {
onClicked().catch(logError);
onClicked().catch(console.error);
});

async function onClicked() {
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Color Picker/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ async function onClicked() {
}

button.connect("clicked", () => {
onClicked().catch(logError);
onClicked().catch(console.error);
});
6 changes: 3 additions & 3 deletions src/Library/demos/Dialogs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ async function createAdvancedDialog() {
}

button_confirmation.connect("clicked", () => {
createConfirmationDialog().catch(logError);
createConfirmationDialog().catch(console.error);
});
button_error.connect("clicked", () => {
createErrorDialog().catch(logError);
createErrorDialog().catch(console.error);
});
button_advanced.connect("clicked", () => {
createAdvancedDialog().catch(logError);
createAdvancedDialog().catch(console.error);
});
1 change: 0 additions & 1 deletion src/Library/demos/Drawing Area/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,3 @@ pub fn main() {
}
});
}

2 changes: 1 addition & 1 deletion src/Library/demos/Drop Zone/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ file_drop_target.connect("drop", (self, value, x, y) => {
try {
bin.child = onDrop(value);
} catch (err) {
logError(err, "Unable to load preview");
console.error(err, "Unable to load preview");
}
bin.remove_css_class("overlay-drag-area");
});
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Email/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ async function onClicked() {
}

button.connect("clicked", () => {
onClicked().catch(logError);
onClicked().catch(console.error);
});
6 changes: 3 additions & 3 deletions src/Library/demos/File Monitor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const monitor_for_dir = file_dir.monitor(
const monitor_for_file = file.monitor(Gio.FileMonitorFlags.NONE, null);

delete_file.connect("clicked", () => {
file.delete_async(GLib.PRIORITY_DEFAULT, null).catch(logError);
file.delete_async(GLib.PRIORITY_DEFAULT, null).catch(console.error);
});

view_file.connect("clicked", () => {
file_launcher.launch(workbench.window, null).catch(logError);
file_launcher.launch(workbench.window, null).catch(console.error);
});

monitor_for_file.connect("changed", (monitor, file, other_file, event) => {
Expand Down Expand Up @@ -80,5 +80,5 @@ edit_file.connect("clicked", () => {
Gio.FileCreateFlags.REPLACE_DESTINATION,
null,
)
.catch(logError);
.catch(console.error);
});
2 changes: 1 addition & 1 deletion src/Library/demos/Font Dialog/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const dialog_custom = new Gtk.FontDialog({
modal: true,
});

custom_button.connect("clicked", () => onClicked().catch(logError));
custom_button.connect("clicked", () => onClicked().catch(console.error));

async function onClicked() {
const result = await dialog_custom.choose_family(
Expand Down
10 changes: 6 additions & 4 deletions src/Library/demos/Launcher/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const file_launcher = new Gtk.FileLauncher({
});

launch_file.connect("clicked", () => {
file_launcher.launch(workbench.window, null).catch(logError);
file_launcher.launch(workbench.window, null).catch(console.error);
});

file_launcher.connect("notify::file", () => {
Expand All @@ -40,7 +40,9 @@ file_launcher.connect("notify::file", () => {
});

file_location.connect("clicked", () => {
file_launcher.open_containing_folder(workbench.window, null).catch(logError);
file_launcher
.open_containing_folder(workbench.window, null)
.catch(console.error);
});

change_file.connect("clicked", () => {
Expand All @@ -49,15 +51,15 @@ change_file.connect("clicked", () => {
.then((file) => {
file_launcher.file = file;
})
.catch(logError);
.catch(console.error);
});

// URI Launcher

uri_launch.connect("clicked", () => {
new Gtk.UriLauncher({ uri: uri_details.text })
.launch(workbench.window, null)
.catch(logError);
.catch(console.error);
});
uri_details.connect("changed", () => {
const text = uri_details.text;
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Location/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ portal.connect(
);

start.connect("clicked", () => {
startSession().catch(logError);
startSession().catch(console.error);
});

close.connect("clicked", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/Library/demos/Open File/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ async function openMultipleFiles() {
}

button_single.connect("clicked", () => {
openFile().catch(logError);
openFile().catch(console.error);
});

button_multiple.connect("clicked", () => {
openMultipleFiles().catch(logError);
openMultipleFiles().catch(console.error);
});
2 changes: 1 addition & 1 deletion src/Library/demos/Save File/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ async function saveFile() {

// Handle button click
button.connect("clicked", () => {
saveFile().catch(logError);
saveFile().catch(console.error);
});
2 changes: 1 addition & 1 deletion src/Library/demos/Screencast/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const output = workbench.builder.get_object("output");
const button = workbench.builder.get_object("button");

button.connect("clicked", () => {
startScreencastSession().catch(logError);
startScreencastSession().catch(console.error);
});

async function startScreencastSession() {
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Screenshot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gio._promisify(
);

button.connect("clicked", () => {
takeScreenshot().catch(logError);
takeScreenshot().catch(console.error);
});

async function takeScreenshot() {
Expand Down
4 changes: 2 additions & 2 deletions src/Library/demos/Select Folder/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ async function selectMultipleFolders() {
}

button_single.connect("clicked", () => {
selectFolder().catch(logError);
selectFolder().catch(console.error);
});

button_multiple.connect("clicked", () => {
selectMultipleFolders().catch(logError);
selectMultipleFolders().catch(console.error);
});
2 changes: 1 addition & 1 deletion src/Library/demos/Session Monitor and Inhibit/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const button_stop = workbench.builder.get_object("button_stop");
let ids = [];

button_start.connect("clicked", () => {
startSession().catch(logError);
startSession().catch(console.error);
});

button_stop.connect("clicked", () => {
Expand Down
1 change: 0 additions & 1 deletion src/Library/demos/Text Colors/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ function rainbowAttributes(str) {
// https://docs.gtk.org/Pango/method.AttrList.to_string.html
return Pango.attr_list_from_string(attrListString);
}

4 changes: 1 addition & 3 deletions src/Library/demos/Video/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import Gio from "gi://Gio";

const video = workbench.builder.get_object("video");

video.file = Gio.File.new_for_uri(
workbench.resolve("./workbench-video.mp4"),
);
video.file = Gio.File.new_for_uri(workbench.resolve("./workbench-video.mp4"));

const click_gesture = new Gtk.GestureClick();

Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Wallpaper/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ async function onClicked() {
}

button.connect("clicked", () => {
onClicked().catch(logError);
onClicked().catch(console.error);
});
4 changes: 2 additions & 2 deletions src/Library/demos/WebSocket Client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function onClosed() {

function onError(_self, err) {
console.log("error");
logError(err);
console.error(err);
}

function onMessage(_self, type, message) {
Expand All @@ -56,7 +56,7 @@ function send(message) {
}

button_connect.connect("clicked", () => {
connect().catch(logError);
connect().catch(console.error);
});

button_disconnect.connect("clicked", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Library/demos/Welcome/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const button = new Gtk.Button({
css_classes: ["suggested-action"],
});
button.connect("clicked", () => {
greet().catch(logError);
greet().catch(console.error);
});
box.append(button);

Expand Down
2 changes: 1 addition & 1 deletion src/PanelCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function PanelCode({
function switchLanguage() {
panel.language = dropdown_code_lang.selected_item.string;
stack_code.visible_child_name = panel.language;
previewer.useInternal().catch(logError);
previewer.useInternal().catch(console.error);
}
switchLanguage();

Expand Down
8 changes: 4 additions & 4 deletions src/PanelUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function PanelUI({

const onBlueprint = unstack(function onBlueprint() {
return blueprint.compile().then(onXML);
}, logError);
}, console.error);

function start() {
stop();
Expand Down Expand Up @@ -144,7 +144,7 @@ export default function PanelUI({
"selected",
(value) => {
const lang = ui_languages[value];
onChangeLang(lang).catch(logError);
onChangeLang(lang).catch(console.error);
},
);

Expand All @@ -153,7 +153,7 @@ export default function PanelUI({
try {
await convertToXML();
} catch (err) {
logError(err);
console.error(err);
// FIXME: Looks like the block() calls don't work
// and the notify::selected signal is emitted
dropdown_selected_signal.block();
Expand All @@ -168,7 +168,7 @@ export default function PanelUI({
if (err instanceof LSPError) {
logBlueprintError(err);
} else {
logError(err);
console.error(err);
}
dropdown_selected_signal.block();
dropdown_ui_lang.set_selected(ui_languages.indexOf(lang_xml));
Expand Down
2 changes: 1 addition & 1 deletion src/Previewer/DBusPreviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function startProcess() {
connection.get_peer_credentials().to_string(),
remote_peer_vanished,
);
if (error) logError(error);
if (error) console.error(error);
});

proxy = await Gio.DBusProxy.new(
Expand Down
4 changes: 2 additions & 2 deletions src/Previewer/External.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function External({ output, builder, onWindowChange }) {
try {
dbus_proxy = await dbus_previewer.getProxy();
} catch (err) {
logError(err);
console.error(err);
}
}

Expand Down Expand Up @@ -51,7 +51,7 @@ export default function External({ output, builder, onWindowChange }) {
.then(() => {
return dbus_previewer.stop();
})
.catch(logError);
.catch(console.error);
}

async function updateXML({ xml, target_id, original_id }) {
Expand Down
2 changes: 1 addition & 1 deletion src/Previewer/Internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Internal({
await panel_ui.update();
await once(bus, "object_root", { timeout: 5000 });
} catch (err) {
logError(err);
console.error(err);
return;
}
}
Expand Down
Loading

0 comments on commit 51d6aa0

Please sign in to comment.