-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error type is missing the source property #141
Comments
TS types would also need an update, like: |
Hey, @AndyOGo! Could you elaborate on what the desired change is? While |
Hi @SerCeMan ! Thank you for your reply. That is my point,
It should change to: export function createErrorFromFrame(frame: ErrorFrame): RSocketError { You are right, other refs can accept any error. For these cases a type guard would be great, like: function isRSocketError(value: any): value is RSocketError {
return Object.prototype.toString.call(value) === "[object Error]" && isRSocketErrorSource(value.source);
}
function isRSocketErrorSource(value: any): value is RSocketErrorSource {
return source && source?.code && source?.explanation && source?.message;
} |
Is my understanding correct that this mostly causes issues with developer experience related to code completion and IDE functionality? If so, I would propose that this is like a "won't fix", since we are primarily focused on #158, which will aim to provide better TypeScript support. Please let me know if I am misunderstanding. |
RSocket error frames are turning into standard
Error()
objects, and expanded by asource
property.The
Error
type does not reflect that fact.Expected Behavior
All errors should be of a custom error type, if applicable.
And type guards could be useful too.
Actual Behavior
Insufficient
Error
type is used, this prohibits auto-completion and discovery.Affected code examples:
rsocket-js/packages/rsocket-core/src/RSocketFrame.js
Lines 189 to 206 in 04bbb8e
Possible Solution
Please see expected above, it shows an
interface
.Your Environment
0.0.25
The text was updated successfully, but these errors were encountered: