MAS 9.2 series core concept
Every row of the table below is a measurement from one of our articles, made on our test system, on the MAS 9.2 series, in the browser preview. The link at each section leads to the article with the details.
Seven errors, side by side#
| What goes wrong | What the framework does | What the user sees | What your code gets |
|---|---|---|---|
| A lifecycle hook throws | catches it, writes one line to the console | the page, complete, with no message | the rest of the hook does not run |
| A click handler throws | catches it in the same way | no message | the rest of the handler does not run |
| Maximo refuses a load | shows a system message, keeps the error in the state of the datasource | the message once, then an empty list | the hook onLoadDataFailed; the call does not throw |
| Maximo refuses a save | shows a system message | the message of Maximo | save() returns an object with error; the change stays unsaved |
| Maximo refuses an action | shows a system message | the message of Maximo | the event invoke-action-failed; the call returns normally |
| A handler name is misspelled | finds no method, does nothing | a button that does nothing | nothing |
| An attribute name is misspelled in a schema | sends it; Maximo answers 200 and leaves it out | an empty field | a record with no such key |
Read the table by its third column. Three rows show the user a message. Four rows show nothing, or an empty place.
The errors that reach the user#
When Maximo refuses a request, the framework opens a system message with the text of Maximo and its message number. That holds for a load, a save and an action.
The message is the easy part. The part that needs your attention is the last column: none of these three calls threw in our measurements. Code that goes on after the call, as if all were well, goes on with wrong assumptions.
For a save, check what the call returns:
const result = await ds.save();
if (result && result.error) {
return; // unsaved, and the user has seen the message
}For a load, the datasource keeps the error in its state, and its controller gets onLoadDataFailed. For an action, listen for the event invoke-action-failed.
- Saving and Updating Data
- Wrong Belief: A Refused Datasource Gets an Empty Answer
- Wrong Belief: onBeforeSaveData Intercepts a Status Change
The errors that reach nobody#
An error in your own code is caught by the framework. We wrote a hook that throws on every visit of its page. The page drew with all its texts, and the only trace was one line in the console that contains the words “Controller event”. The part of the hook after the error never ran.
A hook that can fail therefore needs its own try and catch, and a message for the user:
async pageResumed(page) {
try {
await page.findDatasource('fs_ctl_ds').load();
} catch (e) {
this.app.toast(`Loading failed: ${e.message}`, 'error');
}
}The two misspellings are quieter still. A handler name that no controller has runs nothing, and nothing complains. An attribute name that Maximo does not know passes the build, and Maximo answers with 200 and leaves the name out.
- Using Lifecycle Hooks Correctly
- Event Handling Patterns
- Events and Event Handlers
- Ten Things Every Maximo Developer Believes That Are Wrong
Three habits that make errors visible#
Keep the console open. Search it for “Controller event” after every test of a page. One line there is a hook or a handler that failed.
Keep the network tab open. A request with the status 400 has the reason in its body. A request with 200 and a missing field points to a misspelled attribute.
Never trust the line after an await. After a save, check the result. After a load or an action, check the state of the datasource or listen for the failure.
What to read next#
Controller Basics introduces hooks and handlers. The Controller Methods Cheatsheet and the Datasource Cheatsheet have the calls and their results on one page each.
IBM describes the error messages of Maximo by their codes in the documentation of Maximo Manage, and the answers of the REST API in its documentation of the Maximo REST API.
