mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-06 00:17:00 +08:00
major move of all glib specific bindings and extendable objects from go runtime to go-glib package
This commit is contained in:
@@ -97,3 +97,37 @@ const (
|
||||
StreamErrorDecrypt ErrorCode = C.GST_STREAM_ERROR_DECRYPT // (12) – used when the stream is encrypted and can't be decrypted because this is not supported by the element.
|
||||
StreamErrorDecryptNoKey ErrorCode = C.GST_STREAM_ERROR_DECRYPT_NOKEY // (13) – used when the stream is encrypted and can't be decrypted because no suitable key is available.
|
||||
)
|
||||
|
||||
// GError is a Go wrapper for a C GError in the context of GStreamer. It implements the error interface
|
||||
// and provides additional functions for retrieving debug strings and details.
|
||||
type GError struct {
|
||||
errMsg, debugStr string
|
||||
structure *Structure
|
||||
|
||||
// used for message constructors
|
||||
code ErrorCode
|
||||
}
|
||||
|
||||
// Message is an alias to `Error()`. It's for clarity when this object
|
||||
// is parsed from a `GST_MESSAGE_INFO` or `GST_MESSAGE_WARNING`.
|
||||
func (e *GError) Message() string { return e.Error() }
|
||||
|
||||
// Error implements the error interface and returns the error message.
|
||||
func (e *GError) Error() string { return e.errMsg }
|
||||
|
||||
// DebugString returns any debug info alongside the error.
|
||||
func (e *GError) DebugString() string { return e.debugStr }
|
||||
|
||||
// Structure returns the structure of the error message which may contain additional metadata.
|
||||
func (e *GError) Structure() *Structure { return e.structure }
|
||||
|
||||
// Code returns the error code of the error message.
|
||||
func (e *GError) Code() ErrorCode { return e.code }
|
||||
|
||||
// NewGError wraps the given error inside a GError (to be used with message constructors).
|
||||
func NewGError(code ErrorCode, err error) *GError {
|
||||
return &GError{
|
||||
errMsg: err.Error(),
|
||||
code: code,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user