-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
export function toArrayFromPrimitive(val) { | ||
if (Array.isArray(val)) { | ||
return val; | ||
// Source: https://github.com/hgourvest/node-firebird/blob/master/lib/firebird.msg.json | ||
export const FirebirdConnectionErrors = { | ||
"335544324": "Invalid database handle (no active connection)", | ||
"335544365": "Request referenced an unavailable database", | ||
"335544375": "Unavailable database", | ||
"335544421": "Connection rejected by remote interface", | ||
"335544648": "Connection lost to pipe server", | ||
"335544721": "Unable to complete network request to host", | ||
"335544722": "Failed to establish a connection", | ||
"335544723": "Error while listening for an incoming connection", | ||
"335544724": "Failed to establish a secondary connection for event processing", | ||
"335544725": "Error while listening for an incoming event connection request", | ||
"335544726": "Error reading data from the connection", | ||
"335544727": "Error writing data to the connection", | ||
"335544741": "Connection lost to database", | ||
"335544856": "Connection shutdown" | ||
} | ||
|
||
export function isFirebirdConnectionError(error) { | ||
if (!error || !(error instanceof Error)) { | ||
return false | ||
} | ||
if (String(error.code) in FirebirdConnectionErrors) { | ||
return true | ||
} | ||
|
||
return [val]; | ||
const msg = String(error) | ||
for (const err in FirebirdConnectionErrors) { | ||
if (msg.includes(err)) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |