@@ -136,6 +136,9 @@ func (c *ApplyCommand) Run(args []string) int {
136136 }
137137 }
138138
139+ // This is going to keep track of shadow errors
140+ var shadowErr error
141+
139142 // Build the context based on the arguments given
140143 ctx , planned , err := c .Context (contextOpts {
141144 Destroy : c .Destroy ,
@@ -189,6 +192,12 @@ func (c *ApplyCommand) Run(args []string) int {
189192 c .Ui .Error (fmt .Sprintf ("Error configuring: %s" , err ))
190193 return 1
191194 }
195+
196+ // Record any shadow errors for later
197+ if err := ctx .ShadowError (); err != nil {
198+ shadowErr = multierror .Append (shadowErr , multierror .Prefix (
199+ err , "input operation:" ))
200+ }
192201 }
193202 if ! validateContext (ctx , c .Ui ) {
194203 return 1
@@ -208,6 +217,12 @@ func (c *ApplyCommand) Run(args []string) int {
208217 "Error creating plan: %s" , err ))
209218 return 1
210219 }
220+
221+ // Record any shadow errors for later
222+ if err := ctx .ShadowError (); err != nil {
223+ shadowErr = multierror .Append (shadowErr , multierror .Prefix (
224+ err , "plan operation:" ))
225+ }
211226 }
212227
213228 // Setup the state hook for continuous state updates
@@ -229,6 +244,12 @@ func (c *ApplyCommand) Run(args []string) int {
229244 go func () {
230245 defer close (doneCh )
231246 state , applyErr = ctx .Apply ()
247+
248+ // Record any shadow errors for later
249+ if err := ctx .ShadowError (); err != nil {
250+ shadowErr = multierror .Append (shadowErr , multierror .Prefix (
251+ err , "apply operation:" ))
252+ }
232253 }()
233254
234255 // Wait for the apply to finish or for us to be interrupted so
@@ -304,6 +325,9 @@ func (c *ApplyCommand) Run(args []string) int {
304325 }
305326 }
306327
328+ // If we have an error in the shadow graph, let the user know.
329+ c .outputShadowError (shadowErr , applyErr == nil )
330+
307331 return 0
308332}
309333
0 commit comments