Errors#
This page covers the errors a client reports for an error returned by the server. The error a response carries is described under Anatomy of a Response.
A client reports an error by the mechanism of its language, such as an exception, a status code or a result type. Each error carries a message, and is of one of these kinds, which the requirements name throughout:
The connection error, for a connection that cannot be made, has failed or has closed.
The server error, for an error the server returns, through a call, a stream or an event.
The stream error, for a stream or event that has been removed or cannot be added.
The encoding error, for a value of the right type that fails to encode, or a value that fails to decode.
The argument error, the language’s own, for an argument the program passes that the client rejects.
The interrupt error, the language’s own, for a thread interrupted in a call or a wait.
In a client with error types, the connection, server, stream and encoding errors derive one type of the client’s own, its remote error type. A server exception with a mapped type raises the language’s own type for it, which does not derive the remote error type. A client whose errors are codes, such as C-nano, has a code per kind and no remote error type. It names a server error’s exception by its ids.
An error that another error caused carries the cause’s message after its own.
Server Errors#
errors-server-error [core] [MUST]A call that fails on the server raises the server error.
errors-exception-name [core] [SHOULD]The error exposes the service and name of an exception a service lists.
errors-setter-error [core] [MUST]A property setter that fails on the server raises the error for the server’s exception, as any other call does.
errors-unknown-exception [core] [MUST]A server error naming a service or exception absent from the client’s definitions raises the server error. The message carries the description and the
Service.Nameof the error. This includes an absent exception of a service the client has, and a name the service gives to a class.
errors-request-error [core] [MUST]An error for the whole request raises the server error. The message is the description.
errors-call-after-error [core] [MUST]An error leaves the connection open, and the next call succeeds.
Error Types#
A client with error types reports each exception a service lists with a type of its own, such as an exception class. A mapped exception is one whose definition, in KRPC.GetServices, names a mapped_type: the .NET exception it stands for.
errors-mapped-exceptions [error-types] [MUST]A mapped exception raises the language’s native error type for it, which does not derive the client’s remote error type. A client may raise a class of its own for the exception, with the native type as its only base. An exception with no native type in the language raises the client’s type for it, which derives the server error.
errors-service-exceptions [error-types] [MUST]An exception a service lists, with no mapped type, raises the type the stubs expose for it. This holds for the
KRPCexceptions, such asObjectDestroyedException.
errors-remote-error [error-types] [MUST]Every error of the client’s own derives one type, its remote error type, named in the conventions file. This covers the connection, server and encoding errors, and a service’s exception types. A mapped exception and the language’s own errors, such as its argument error, do not derive it. A client whose errors are codes has no such type.
errors-stream-remote-error [error-types, streams] [MUST]The stream error derives the client’s remote error type.
Messages#
errors-message-prefix [core] [MUST]A client without error types, or whose errors are codes in place of types, starts the message with
Service.Name:, the service and name the error carries.
errors-message [core] [MUST]The message is the description, followed by
Server stack trace:and the stack trace when the server sends one. A client may cut the end off the message, keeping at least the prefix of errors-message-prefix.
errors-whole-message [core] [SHOULD]The message holds the whole description and stack trace.
errors-description [core] [MUST]The message carries the description unchanged, apart from any cut allowed by errors-message.