↓ Skip to main content
A gouache painting of seven round signal lamps in a row on a pale wall. Three lamps glow orange, and four are dark teal and unlit.

Error Handling Basics

A Maximo developer expects an error to end in a message box. In an app of Maximo Mobile, some errors do. Others end in one line in the console of the browser, and a few end nowhere at all. This page sorts them, so that you know which errors need your own code to become visible.

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 wrongWhat the framework doesWhat the user seesWhat your code gets
A lifecycle hook throwscatches it, writes one line to the consolethe page, complete, with no messagethe rest of the hook does not run
A click handler throwscatches it in the same wayno messagethe rest of the handler does not run
Maximo refuses a loadshows a system message, keeps the error in the state of the datasourcethe message once, then an empty listthe hook onLoadDataFailed; the call does not throw
Maximo refuses a saveshows a system messagethe message of Maximosave() returns an object with error; the change stays unsaved
Maximo refuses an actionshows a system messagethe message of Maximothe event invoke-action-failed; the call returns normally
A handler name is misspelledfinds no method, does nothinga button that does nothingnothing
An attribute name is misspelled in a schemasends it; Maximo answers 200 and leaves it outan empty fielda 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.

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.

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.