fix: always expose DC-prefixed errors to users in safeErrorMessage
This commit is contained in:
@@ -97,6 +97,9 @@ function safeErrorMessage(error) {
|
||||
if (!error) return 'An internal error occurred';
|
||||
const msg = error.message || String(error);
|
||||
|
||||
// Always expose DC-prefixed user-facing errors
|
||||
if (/\[DC-\d+\]/.test(msg)) return msg;
|
||||
|
||||
// Detect port conflict errors
|
||||
const portMatch = msg.match(/exposing port TCP [^:]*:(\d+)/);
|
||||
if (portMatch || msg.includes('port is already allocated') || msg.includes('ports are not available')) {
|
||||
@@ -104,7 +107,7 @@ function safeErrorMessage(error) {
|
||||
return `[DC-200] Port ${port} is already in use. Try a different port or stop the service using that port first.`;
|
||||
}
|
||||
|
||||
// Only expose short, user-facing messages
|
||||
// Only expose short, user-facing messages (no paths, stack traces, or internal details)
|
||||
if (msg.length < 200 && !msg.includes('/') && !msg.includes('\\') && !msg.includes(' at ')) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user