GDBCommandFailedError.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 13 Sep 2017 22:11:51 +0100
changeset 88 90c50fd6374c
child 91 472a4841a8b6
permissions -rw-r--r--
Introduced new exception class: `GDBCommandFailedError` ...that is raised from `GDBDebugger >> #send:andWait:` when used synchronously (that is, when waiting for command result). This allows senders to catch the command failures specifically.

"{ Package: 'jv:libgdbs' }"

"{ NameSpace: Smalltalk }"

GDBError subclass:#GDBCommandFailedError
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'GDB-Core-Exeptions'
!

!GDBCommandFailedError class methodsFor:'raising'!

raiseForResult: result
    <resource: #skipInDebuggersWalkBack>

    self newException
        result: result;
        raise.

    "Created: / 13-09-2017 / 14:47:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBCommandFailedError methodsFor:'accessing'!

command
    "Returns the command (as `GDBCommand`) that failed."

    ^ self result command

    "Created: / 13-09-2017 / 14:40:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

result
    "Returns the command result (as `GDBCommandResult`) for the failure"

    ^ self parameter

    "Created: / 13-09-2017 / 14:41:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

result: aGDBCommandResult
    parameter := aGDBCommandResult.
    messageText := 'Command failed: ', (aGDBCommandResult propertyAt: 'msg').

    "Created: / 13-09-2017 / 14:48:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !