Skip to content

Commit da02a75

Browse files
committed
docs: improve error messages
Signed-off-by: Dale Lane <dale.lane@uk.ibm.com>
1 parent c05a56a commit da02a75

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/com/kylecorry/ml4k/ML4KComponent.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ public final class ML4KComponent extends AndroidNonvisibleComponent {
7272
private final static String EXPLAIN_API_KEY_TYPE_NUMBERS = "You created a machine learning project to recognise numbers, so you can only use the numbers ML blocks in this project.";
7373
private final static String EXPLAIN_API_KEY_TYPE_IMAGES = "You created a machine learning project to recognise images, so you can only use the images ML blocks in this project.";
7474
private final static String EXPLAIN_API_KEY_TYPE_SOUNDS = "You created a machine learning project to recognise sounds, so you cannot use that block";
75-
private final static String EXPLAIN_ML_MODEL_NEEDED = "Please train a machine learning model before you try to do this.";
75+
private final static String EXPLAIN_ML_MODEL_NEEDED = "Please train a machine learning model before you try to do this. You must do this in your App Inventor project, using the 'TrainNewModel' block.";
76+
private final static String EXPLAIN_ML_MODEL_NOTREADY = "Your machine learning model is still training. Please wait for this to complete.";
77+
private final static String EXPLAIN_ML_MODEL_FAILED = "Sorry! Your machine learning model failed to train.";
7678

7779

7880

@@ -478,9 +480,19 @@ private void checkTensorFlowJsStatus() {
478480
private void classifyImageWithTensorflow(final String path) {
479481
initialiseTensorFlow();
480482

481-
if (!webPageObj.getModelStatus().equals("Available")) {
482-
displayErrorMessage(EXPLAIN_ML_MODEL_NEEDED);
483-
return;
483+
switch (webPageObj.getModelStatus()) {
484+
case "Not trained":
485+
displayErrorMessage(EXPLAIN_ML_MODEL_NEEDED);
486+
return;
487+
case "Failed":
488+
displayErrorMessage(EXPLAIN_ML_MODEL_FAILED);
489+
return;
490+
case "Training":
491+
displayErrorMessage(EXPLAIN_ML_MODEL_NOTREADY);
492+
return;
493+
case "Available":
494+
// yay, we're all good!
495+
break;
484496
}
485497

486498
runInBackground(new Runnable() {

0 commit comments

Comments
 (0)