Repository: paritytech/substrate
File: frame/support/procedural/src/pallet/expand/hooks.rs (Rust)

Code before:
					pallet_name,
					on_chain_version,
					current_version,
				);

				return Err("On chain and current storage version do not match. Missing runtime upgrade?");
			}
		}
	} else {
		quote::quote! {
			let on_chain_version = <Self as #frame_support::traits::GetStorageVersion>::on_chain_storage_version();

			if on_chain_version != #frame_support::traits::StorageVersion::new(0) {
				let pallet_name = <
					<T as #frame_system::Config>::PalletInfo
					as
					#frame_support::traits::PalletInfo
				>::name::<Self>().unwrap_or("<unknown pallet name>");

				#frame_support::log::error!(
					target: #frame_support::LOG_TARGET,
					"{pallet_name}: On chain storage version {on_chain_version:?} is set to non zero,\
					 while the pallet is missing the `#[pallet::storage_version(VERSION)]` attribute.",
				);

				return Err("On chain storage version set, while pallet doesn't \
							has the `#[pallet::storage_version(VERSION)]` attribute.");
			}
		}
	};

	quote::quote_spanned!(span =>
		#hooks_impl

		impl<#type_impl_gen>
			#frame_support::traits::OnFinalize<<T as #frame_system::Config>::BlockNumber>
			for #pallet_ident<#type_use_gen> #where_clause
		{
			fn on_finalize(n: <T as #frame_system::Config>::BlockNumber) {
				#frame_support::sp_tracing::enter_span!(
					#frame_support::sp_tracing::trace_span!("on_finalize")
				);
				<
					Self as #frame_support::traits::Hooks<
						<T as #frame_system::Config>::BlockNumber
					>
				>::on_finalize(n)
			}
		}

		impl<#type_impl_gen>

Review comment (suggestion):
```suggestion
				return Err("On chain storage version set, while the pallet doesn't \
```

Code after:
					pallet_name,
					on_chain_version,
					current_version,
				);

				return Err("On chain and current storage version do not match. Missing runtime upgrade?");
			}
		}
	} else {
		quote::quote! {
			let on_chain_version = <Self as #frame_support::traits::GetStorageVersion>::on_chain_storage_version();

			if on_chain_version != #frame_support::traits::StorageVersion::new(0) {
				let pallet_name = <
					<T as #frame_system::Config>::PalletInfo
					as
					#frame_support::traits::PalletInfo
				>::name::<Self>().unwrap_or("<unknown pallet name>");

				#frame_support::log::error!(
					target: #frame_support::LOG_TARGET,
					"{}: On chain storage version {:?} is set to non zero,\
					 while the pallet is missing the `#[pallet::storage_version(VERSION)]` attribute.",
					pallet_name,
					on_chain_version,
				);

				return Err("On chain storage version set, while the pallet doesn't \
							have the `#[pallet::storage_version(VERSION)]` attribute.");
			}
		}
	};

	quote::quote_spanned!(span =>
		#hooks_impl

		impl<#type_impl_gen>
			#frame_support::traits::OnFinalize<<T as #frame_system::Config>::BlockNumber>
			for #pallet_ident<#type_use_gen> #where_clause
		{
			fn on_finalize(n: <T as #frame_system::Config>::BlockNumber) {
				#frame_support::sp_tracing::enter_span!(
					#frame_support::sp_tracing::trace_span!("on_finalize")
				);
				<
					Self as #frame_support::traits::Hooks<
						<T as #frame_system::Config>::BlockNumber
					>
				>::on_finalize(n)
			}
		}