diff --git a/packages/phoenix/src/platform/node/filesystem.js b/packages/phoenix/src/platform/node/filesystem.js
index 85b9e84c..d8ae9994 100644
--- a/packages/phoenix/src/platform/node/filesystem.js
+++ b/packages/phoenix/src/platform/node/filesystem.js
@@ -20,7 +20,7 @@ import fs from 'fs';
import path_ from 'path';
import modeString from 'fs-mode-to-string';
-import { ErrorCodes, PosixError } from '../PosixError.js';
+import { ErrorCodes, PosixError } from '@heyputer/puter-js-common/src/PosixError.js';
function convertNodeError(e) {
switch (e.code) {
diff --git a/packages/phoenix/src/platform/puter/filesystem.js b/packages/phoenix/src/platform/puter/filesystem.js
index ca60e2fe..42271561 100644
--- a/packages/phoenix/src/platform/puter/filesystem.js
+++ b/packages/phoenix/src/platform/puter/filesystem.js
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { ErrorCodes, PosixError } from '../PosixError.js';
+import { ErrorCodes, PosixError } from '@heyputer/puter-js-common/src/PosixError.js';
function convertPuterError(e) {
// Handle Puter SDK errors
diff --git a/packages/phoenix/src/puter-shell/coreutils/errno.js b/packages/phoenix/src/puter-shell/coreutils/errno.js
index dd36d8dd..db74b2f6 100644
--- a/packages/phoenix/src/puter-shell/coreutils/errno.js
+++ b/packages/phoenix/src/puter-shell/coreutils/errno.js
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { ErrorCodes, ErrorMetadata, errorFromIntegerCode } from '../../platform/PosixError.js';
+import { ErrorCodes, ErrorMetadata, errorFromIntegerCode } from '@heyputer/puter-js-common/src/PosixError.js';
import { Exit } from './coreutil_lib/exit.js';
const maxErrorNameLength = Object.keys(ErrorCodes)
diff --git a/packages/phoenix/src/puter-shell/coreutils/touch.js b/packages/phoenix/src/puter-shell/coreutils/touch.js
index 8f15f13c..5b32067a 100644
--- a/packages/phoenix/src/puter-shell/coreutils/touch.js
+++ b/packages/phoenix/src/puter-shell/coreutils/touch.js
@@ -18,7 +18,7 @@
*/
import { Exit } from './coreutil_lib/exit.js';
import { resolveRelativePath } from '../../util/path.js';
-import { ErrorCodes } from '../../platform/PosixError.js';
+import { ErrorCodes } from '@heyputer/puter-js-common/src/PosixError.js';
export default {
name: 'touch',
diff --git a/packages/phoenix/test/coreutils/errno.js b/packages/phoenix/test/coreutils/errno.js
index fbb63b53..34fc7867 100644
--- a/packages/phoenix/test/coreutils/errno.js
+++ b/packages/phoenix/test/coreutils/errno.js
@@ -19,7 +19,7 @@
import assert from 'assert';
import { MakeTestContext } from './harness.js'
import builtins from '../../src/puter-shell/coreutils/__exports__.js';
-import { ErrorCodes, ErrorMetadata } from '../../src/platform/PosixError.js';
+import { ErrorCodes, ErrorMetadata } from '@heyputer/puter-js-common/src/PosixError.js';
export const runErrnoTests = () => {
describe('errno', function () {
diff --git a/packages/phoenix/src/platform/PosixError.js b/packages/puter-js-common/src/PosixError.js
similarity index 94%
rename from packages/phoenix/src/platform/PosixError.js
rename to packages/puter-js-common/src/PosixError.js
index 0fc136a5..3d026b8c 100644
--- a/packages/phoenix/src/platform/PosixError.js
+++ b/packages/puter-js-common/src/PosixError.js
@@ -1,9 +1,9 @@
/*
* Copyright (C) 2024 Puter Technologies Inc.
*
- * This file is part of Phoenix Shell.
+ * This file is part of Puter.
*
- * Phoenix Shell is free software: you can redistribute it and/or modify
+ * Puter is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-export const ErrorCodes = {
+const ErrorCodes = {
EACCES: Symbol.for('EACCES'),
EADDRINUSE: Symbol.for('EADDRINUSE'),
ECONNREFUSED: Symbol.for('ECONNREFUSED'),
@@ -37,7 +37,7 @@ export const ErrorCodes = {
};
// Codes taken from `errno` on Linux.
-export const ErrorMetadata = new Map([
+const ErrorMetadata = new Map([
[ErrorCodes.EPERM, { code: 1, description: 'Operation not permitted' }],
[ErrorCodes.ENOENT, { code: 2, description: 'File or directory not found' }],
[ErrorCodes.EIO, { code: 5, description: 'IO error' }],
@@ -57,7 +57,7 @@ export const ErrorMetadata = new Map([
[ErrorCodes.ECONNREFUSED, { code: 111, description: 'Connection refused' }],
]);
-export const errorFromIntegerCode = (code) => {
+const errorFromIntegerCode = (code) => {
for (const [errorCode, metadata] of ErrorMetadata) {
if (metadata.code === code) {
return errorCode;
@@ -66,7 +66,7 @@ export const errorFromIntegerCode = (code) => {
return undefined;
};
-export class PosixError extends Error {
+class PosixError extends Error {
// posixErrorCode can be either a string, or one of the ErrorCodes above.
// If message is undefined, a default message will be used.
constructor(posixErrorCode, message) {
@@ -141,3 +141,10 @@ export class PosixError extends Error {
return new PosixError(ErrorCodes.ETIMEDOUT, message);
}
}
+
+module.exports = {
+ ErrorCodes,
+ ErrorMetadata,
+ errorFromIntegerCode,
+ PosixError,
+}