throw
A minimalistic way to raise an ABAP exception, from a text passed directly or, with no argument, from the system fields a preceding MESSAGE statement filled, as a static method or through an interface.
zcl_throw raises a static exception from a text passed directly, as in throw( 'Something bad happened' ), or, called with no argument, from whatever a preceding MESSAGE statement wrote into the system fields. It can be called as a static method, through a new instance, or through the zif_throw interface a class implements to alias its own throw method to it. It stops at raising the exception; what a caller does when it catches one is outside its scope.
Facts
Where it sits
Who is behind it
In the atlas: maintains 9@abapifymaintainerPetr PlenkovContributes to this
In the atlas: contributes to 13@ThePlenkov1 contributor
Before choosing this
Signals
ActivityQuietRelease and repository quiet for 26 months
Both observable publication channels have been quiet for at least 24 full months. This may be normal for stable software; check whether its current state still fits your use.
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- does not say
Connections
Turning a failure into a response a client can act on
Helper class for classic ABAP dynpro field handling and popups
Fetch API-style HTTP polyfill for cloud and classic ABAP
Download
README
quoted from abapify/throw under MIT, readThrow anything as exception
Throw any object as exception in a minimalistic way. The prototype for this class is native javascript throw.
Here is the idea
we should be able to do something like:
throw( 'Something bad happened' )
or even
message e001(zmy_message_class) with 'this` 'and' 'that' into data(lv_dummy).
throw( ).
In both cases we expect a static exception should be raised with a text message from a given text or just inherited from a system message. That's it.
Usage
Via static method
zcl_throw=>from( 'Error happenned' ).
or
message e001(zmy_message_class) with 'this` 'and' 'that' into data(lv_dummy).
zcl_throw=>from( ).
Via instance
Not sure if we even need this way, may be for extensions with inherited classes
new zcl_throw( )->throw( 'Error happenned' ).
or
message e001(zmy_message_class) with 'this` 'and' 'that' into data(lv_dummy).
new zcl_throw( )->throw( ).
Via interface
You can also implement ZIF_THROW interface in your class or just inherit from ZCL_THROW class
In short here is the pattern how you can use it:
class zcl_your_class definition.
public section.
interfaces zif_throw.
private section.
aliases throw for zif_throw~throw.
methods do_something raising cx_static_check.
endclass.
class zcl_your_class implementation.
method zif_throw~throw.
zcl_throw=>from( object ).
endmethod.
method do_something.
if something_bad_happened( ).
throw( 'Something bad happened' ).
endif.
endmethod.
endclass.
Dependencies
- assert is used in unit tests for throw
History
Others providing
Compare all 8 on the Error handling page →- ABAP-PRCABAP-PRCA framework for custom multi-step ABAP processes: a process class declares the states, and the framework runs each document through them and monitors the run.independent, abapFramework for multi-step ABAP processes with monitoringfrom ABAP
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versionsfrom CAP
- cds-error-outboxcds-error-outboxA CAP plugin that captures errors raised by CAP services into a database entity, deduplicates them so a repeating failure is one alert, and mails it over SMTP or Microsoft Graph.independent, capCaptures CAP service errors, deduplicates them and mails alertsfrom CAP
- RESULT-for-ABAPRESULT-for-ABAPAn ABAP implementation of the result pattern: a method returns an object built with ok or fail instead of raising an exception for an expected failure, and several results combine into one.independent, abapResult pattern for ABAP instead of exceptions for expected failuresfrom ABAP
- EITHER-FOR-ABAPEITHER-FOR-ABAPAn ABAP class implementing the Either pattern, holding a success value or an error from a method call in one object, with checks for which side it holds and exceptions for misuse.independent, abapABAP class implementing the Either patternfrom ABAP
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtimefrom CAP
- sap-usi-exceptionsap-usi-exceptionA shared root exception class and text getter API used across SchwarzIT's USI ABAP developments, converting an exception's text into a common format such as BAPIRET2 or SYMSG.independent, abapShared root exception class and text getter for USI developmentsfrom ABAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
abaplint
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:abapify-throw- JSON
- /artifacts/abapify-throw.json
- MCP
- Connecting an agent