arduino / arduino/Arduino

uploadUsingProgrammer problems should fail gracefully

Open
#10,032 2 comments 1 reaction 0 assignees View on GitHub
Component: Uploading Type: Bug
Dominant language
Java
Stars
14.6k
Forks
7k
PR merge metrics
No merged PRs in 30d

Description

I sat and looked at this message for a long time, and upgraded my Arduino version, before determing what specific user error I was making- I had the wrong programmer selected. Based on the issues and other Googling I'm not the first person to get this NPE. It would be helpful if there was a better error message in the console, at a minimum.

I assume that `targetPlatform` is null [at this point in the code](https://github.com/arduino/Arduino/blob/ef8d669f6a49a438430aae3e1f29161e34ce5d63/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java#L295), so `targetPlatform.getProgrammer(..);` fails.

```
java.lang.NullPointerException
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingProgrammer(SerialUploader.java:295)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:90)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
at processing.app.SketchController.upload(SketchController.java:732)
at processing.app.SketchController.exportApplet(SketchController.java:703)
at processing.app.Editor$UploadHandler.run(Editor.java:2047)
at java.lang.Thread.run(Thread.java:748)
```

somewhat-related issues: #7412 #7034

Contributor guide

Open the contributing guide

Research direction

Start in arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java at line 295, using the reported stack trace to follow uploadUsingProgrammer. Reproduce the wrong-programmer selection and verify that it reports a clear console error instead of the NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.