Skip to content

fix(gcode): report the real OS error when G-code export fails#11066

Open
BenJule wants to merge 1 commit into
bambulab:masterfrom
BenJule:upstream/fix-gcode-export-diagnostics
Open

fix(gcode): report the real OS error when G-code export fails#11066
BenJule wants to merge 1 commit into
bambulab:masterfrom
BenJule:upstream/fix-gcode-export-diagnostics

Conversation

@BenJule

@BenJule BenJule commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Problem

When G-code export fails, BambuStudio always shows:

G-code export to <file> failed. Is the disk full?

This is guessed, not measured. GCodeOutputStream only checks ferror() and GCode::export_gcode() discards the real errno from the failed fwrite/fflush. Large multi-colour models produce multi-GB G-code, and the write can fail for several different reasons — a full temp volume, a read-only path, an antivirus/cloud-sync lock, or a disk quota — all of which are reported identically as 'disk full'. Users (this came from a real 4-colour model export on Windows) are left guessing.

Fix

  • Capture errno at the first failed fwrite/fflush in GCodeOutputStream.
  • Expose it via get_last_error() (strerror).
  • Include the real cause in the export-failure message, e.g. 'No space left on device' vs 'Permission denied', while keeping the original disk-full hint as a fallback when no errno was recorded.

No behavioural change other than a more accurate error message. Small, self-contained: src/libslic3r/GCode.cpp + GCode.hpp (+25/-3).

The G-code writer only checked ferror() and always threw 'Is the disk full?',
discarding the actual errno from the failed fwrite/fflush. On a multi-colour
model that produces a multi-GB .gcode the write can fail for several reasons
(full temp volume, read-only path, antivirus lock, disk quota) — all reported
as 'disk full', which misleads users.

Capture errno at the first failed fwrite/fflush in GCodeOutputStream, expose it
via get_last_error(), and include strerror() in the export failure message
(e.g. 'No space left on device') while keeping the disk-full hint as fallback.

@Diatom-Bambu Diatom-Bambu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your submission; this certainly makes the error message more detailed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants