socks icon indicating copy to clipboard operation
socks copied to clipboard

Error codes

Open rightaway opened this issue 2 years ago • 3 comments

Error messages like Socks4 Proxy rejected incoming bound connection - Failed could change and are concatenated from 2 different parts sometimes like ERRORS.Socks4ProxyRejectedIncomingBoundConnection and Socks4Response[data[1]] https://github.com/JoshGlazebrook/socks/blob/6c777c229cf37aaf81ca82c9e06c0de2faead332/src/client/socksclient.ts#L566

To do error handling we would need to do string manipulation on error.message which isn't reliable. It will be better if we could have error.code and error.detail property if the error has detail information in addition to human readable error.message.

/* with detail */
{
    code: "SOCKS4_REJECTED_INCOMING",
    detail: "Failure",
    message: "Socks4 Proxy rejected incoming bound connection - Failure"
}

/* without detail */
{
    code: "INTERNAL_ERROR",
    message: "SocksClient internal error (this should not happen)"
}

rightaway avatar Sep 07 '21 08:09 rightaway

Seems reasonable, I'll try to get this done soon!

JoshGlazebrook avatar Sep 15 '21 02:09 JoshGlazebrook

Could you also add a boolean property such as error.fatal whether the error can be retried or not? Some errors like server errors can be retried but others like client errors mean something is wrong in the configuration and retrying won't help until the problem is fixed. This property will make better error handling possible.

/* client */
{
    code: "INVALID_DESTINATION_HOST",
    message: "An invalid destination host was provided.",
    fatal: true
}

/* server */
{
    code: "SOCKS4_REJECTED_INCOMING",
    detail: "Failure",
    message: "Socks4 Proxy rejected incoming bound connection - Failure",
    fatal: false
}

Are some errors in https://github.com/JoshGlazebrook/socks/blob/master/src/common/constants.ts not being thrown? I see about half of them being used in https://github.com/JoshGlazebrook/socks/blob/master/src/client/socksclient.ts.

rightaway avatar Sep 16 '21 08:09 rightaway

Seems reasonable, I'll try to get this done soon!

@JoshGlazebrook Do you think you would be able to add these?

rightaway avatar Apr 19 '22 06:04 rightaway